1

我有这个工作代码

if ($.browser.msie && parseInt($.browser.version, 10) < 9){
}
else{
    $('.insert_checkpassword').toggle($('#password').val().length > 0);
}

可以做得更小吗?

我想对所有浏览器执行此代码,但不是更小的版本 9

像这样

if IS NOT ($.browser.msie && parseInt($.browser.version, 10) < 9){
    $('.insert_checkpassword').toggle($('#password').val().length > 0);
}
4

2 回答 2

0

You need to use logical not operator !, you can read more about logical operators here.

if (!( $.browser.msie && parseInt($.browser.version, 10) < 9)){
    $('.insert_checkpassword').toggle($('#password').val().length > 0);
}
于 2013-04-16T09:07:20.297 回答
0

This would do it:

if (!$.browser.msie || parseInt($.browser.version, 10) >= 9) {
    $('.insert_checkpassword').toggle($('#password').val().length > 0);
}

Note that $.browser is deprecated and shouldn't be relied upon.

于 2013-04-16T09:07:54.370 回答