How to use not operator in jquery

bruce
bruce
Member
40 Points
10 Posts

Hi,

 

Following statement is to change the background color of cell to red .


$("a").parent().css('background-color', 'red');
 


my requirement is not change the background color to red ,if the anchor in the cell with background-color is Orchid.

how to use not operator using jquery.

Views: 8684
Total Answered: 1
Total Marked As Answer: 0
Posted On: 31-Jul-2015 07:05

Share:   fb twitter linkedin
Answers
Brian
Brian
Moderator
2232 Points
14 Posts
         

Hi Bruce,

Use JQuery Filter method as:

$('a').filter(function () {
 
var match = 'rgb(0, 0, 0)'; // match background-color: black 
 
return ($(this).css('background-color') != match);
}).parent().css(
'background-color', 'red');

Above example is for black color. In your case use appropriate rdb for Orchid.

Posted On: 01-Aug-2015 23:19
 Log In to Chat