I’m trying to use if and else in a jQuery Function based in the backgroundColor of a li tag, for exemple: If this backgroundColor = #ccc do something, else, do other. I tried like this:
if ($(this).css('backgroundColor = #EBE5C5')) {
but it doesnt work right, can you help me?
Hmm,thanks a lot, but it still not working right, see the full function right here:
$(function(){
$('.slider-nav li')
.mouseover(function(){
if ($(this).css('background-color') == "#EBE5C5") {
$(this).stop().animate({'backgroundColor':'#c0ba9f'},250);
}
})
.mouseout(function(){
$(this).stop().animate({'backgroundColor':'#EBE5C5'},250);
})
});
Should be something like this:
Remember that one equals sign is assignment.
Here is the jsFiddle:
http://jsfiddle.net/F6WeR/1/