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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6539459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:01:33  来源:igfitidea点击:

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

jquery

提问by Evanss

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

我需要反转以下代码。如果宽度不是 500 像素,我如何让动画运行。

$(".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

谢谢

回答by FishBasketGordo

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

==比较运算符的反面是!=

回答by Naftali aka Neal

===> !=

===> !=

====> !==

====> !==

Equal and its opposite

相等和相反

回答by Brad Christie

!=

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 (1 === '1')[不等于])

回答by Benjamin.MK

if ("one" !== 1 )

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

将评估为true,字符串"one"不等于数字1