开发者

jquery disable by class

开发者 https://www.devze.com 2023-01-10 22:16 出处:网络
<l开发者_StackOverflow中文版i style=\"display: block;\" class=\"selectlist-item\">fsdafkds</li>
<l开发者_StackOverflow中文版i style="display: block;" class="selectlist-item">fsdafkds</li>

how can i disable a controller by class by jquery


If you want to hide it using jQuery:

$('.classname').hide();

The . is the class-selector. Same as in CSS.


Your question isn't clear; you can't disable non-form field elements.

But if you want to select an element based on its class, here is how you can do that:

$('.selectlist-item')

Notice the dot before class name. This is similar to CSS actually.

More Info:

  • jQuery Class Selector


This is the code I use to disable or re-enable a control:

function handleControlDisplay(className, foundCount, checked) {



    var button = jQuery(className);



    if (foundCount > 0 && foundCount == checked) {

        // enable

        button.removeAttr("disabled");

    }

    else {

        // set the disabled attribute

        button.attr("disabled", "true");

    };

}
0

精彩评论

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