Deselect an ID that would otherwise be selected by

2019-08-19 23:34发布

问题:

I have a page where all inputs are assigned a behavior: $("input").blur(function () {

and I need to exclude a checkbox that has a specific id:

  <input type="checkbox" id="allButMe" onchange="billingSameChanged();" value="true"/> 

thx

回答1:

Use jQuery's not selector like this:

$("input:not(#allButMe)").blur(function() { });


回答2:

use jQuery not here

$("input").not("#allButMe").blur(function() {});