开发者

is there anyway in jquery to have a class selector but without one id

开发者 https://www.devze.com 2023-01-13 10:31 出处:网络
i have this code: function DisableDropDownsMonth() { $(\".filterDropdown\").val(0); $(\".filterDropdown\").attr(\"disabled\", \"disabled\");

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/

0

精彩评论

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