i have this code:
function DisableDropDownsMonth() {
$(".filterDropdown").val(0);
$(".filterDropdown").attr("disabled", "disabled");
}
to disable a bunch of select dropdowns that all have this class. I have a new requirement to call this on every ".filterDropdo开发者_如何转开发wn" EXCEPT if the id = "#firstDropdown"
is there any syntax for this in jquery?
You can use the :not()
selector to exclude it, like this:
$(".filterDropdown:not(#firstDropDown)").attr("disabled", "disabled");
Or possibly judging by your ID, :gt()
like this:
$(".filterDropdown:gt(0)").attr("disabled", "disabled");
This would disable all except the very first class="filterDropdown"
in the DOM.
should be something like $(".filterDropdown:not(#firstDropdown)");
you can use following syntax
$(".filterDropdown[id!=firstDropdown]").attr("disabled", "disabled");
http://api.jquery.com/attribute-not-equal-selector/
精彩评论