Evans Evans - 7 months ago 20
Javascript Question

jQuery - how to write 'if not equal to' (opposite of ==)

I need to reverse of the following code. How can I make the animation run if the width is NOT 500px.

$(".image-div").not(this).each(function() {
if ($(this).css('width') == '500px') {
$(this).animate({
width: '250px'
}, 500, function() {
// Animation complete.
});
}


});


In other words, what the opposite of this?: ==

Thanks

Answer

The opposite of the == compare operator is !=.

Comments