开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜