jQuery .not(), multiple excludes with id

2019-02-08 06:25发布

问题:

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?

回答1:

Just add another comma (multiple selector), for example:

$("#reset").click(function() {
  $(':input','#fundingpossibility')
  .not(':button, :submit, :reset, :hidden, #test')
  .val('');
});