开发者

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

开发者 https://www.devze.com 2023-03-17 00:30 出处:网络
I need to reverse of the follow开发者_JAVA技巧ing code. How can I make the animation run if the width is NOT 500px.

I need to reverse of the follow开发者_JAVA技巧ing 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


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


== => !=

=== => !==

Equal and its opposite


!=

For example,

if ("apple" != "orange")
  // true, the string "apple" is not equal to the string "orange"

Means not. See also the logical operators list. Also, when you see triple characters, it's a type sensitive comparison. (e.g. if (1 === '1') [not equal])


if ("one" !== 1 )

would evaluate as true, the string "one" is not equal to the number 1

0

精彩评论

暂无评论...
验证码 换一张
取 消