开发者

jQuery event on select change except one select

I have a page with seve开发者_StackOverflow社区ral select buttons. I would like for a function to be called in jQuery any select function except for say one with id="Select1" is changed. I know that I can link the function to each select that I want liked to the event, but it would be much more convenient to specify those that should be excluded than list all that should be included.

Would it be possible for one specific class of selects to cause a change?


$('select:not(#Select1)');

or if you're specifying several to exclude:

$('select:not(.excludeClass)');

the same can be achieved with method chaining:

$('select').not('#Select1');


$("select.myselectClass").change(function(){
});

will fire the change event for select events with class myselectClass only.

Better to select the combos for which you want to fire the event rather than using the :not. If you want to remove event for more than one select box then it would be more complicated.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜