开发者

How do I do an "or" statement with the jQuery :not() function?

So, I'm trying to figure out if this is possible or not. I have a .find(':input:not(button)') function in my code and I'm trying to 开发者_Go百科exclude additional things besides the button. So I'm looking for a way to do this: .find(:input:not(button || otherthing)'). Is this possible? I know that syntax isn't correct as it's not working, but I'm hoping that some of you know how to do this. Thanks for your help.


you can use the function instead of the filter, for example:

$(element).find('input').not('button').not('otherthing');

You can also do this which is much simpler:

    $(element).find('input:not(button, otherthing)');

Source: http://api.jquery.com/not-selector/


:not(button):not(otherthing)

will definitely work. jQuery may also accept this syntax, but don't hold me to it:

:not(button,otherthing)


Let's do a little boolean algebra shall we?

~(A OR B) = ~A AND ~B

So this translates to

.find('input:not(button)').filter('input:not(otherthing)')
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜