Javascript jQuery .not(),带有 id 的多个排除
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4545211/
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-23 12:53:18 来源:igfitidea点击:
jQuery .not(), multiple excludes with id
提问by Alex Berg
I got this small piece of code to reset a form:
我得到了一小段代码来重置表单:
$("#reset").click(function() {
$(':input','#fundingpossibility')
.not(':button, :submit, :reset, :hidden')
.val('');
});
I'd like to add an input field with, let's say, an id of #test
to the .not()
selector. I've tried various things, but can't make it to work. Does anyone have any ideas?
我想补充的输入栏,比方说,一个id的#test
给.not()
选择。我尝试了各种方法,但无法使其正常工作。有没有人有任何想法?
回答by Nick Craver
Just add another comma (multiple selector), for example:
只需添加另一个逗号(多个选择器),例如:
$("#reset").click(function() {
$(':input','#fundingpossibility')
.not(':button, :submit, :reset, :hidden, #test')
.val('');
});