jQuery - 如何写'如果不等于'(与==相反)

Eva*_*nss 41 jquery

我需要反转以下代码.如果宽度不是500px,我该如何使动画运行.

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


    });
Run Code Online (Sandbox Code Playgroud)

换句话说,与此相反的是什么?:==

谢谢

Fis*_*rdo 80

==比较运算符相反的是!=.


Nea*_*eal 35

== => !=

=== => !==

平等和相反


Bra*_*tie 18

!=
Run Code Online (Sandbox Code Playgroud)

例如,

if ("apple" != "orange")
  // true, the string "apple" is not equal to the string "orange"
Run Code Online (Sandbox Code Playgroud)

意思不是.另请参见逻辑运算符列表.此外,当您看到三重字符时,它是一种类型敏感的比较.(例如if (1 === '1')[不相等])