禁用除特定类之外的所有表单元素(Disable all form elements except particular class)
我是JQuery的新手。 我需要禁用除此类custom_specialcase之外的所有元素。
谢谢
<div> <button>B1</button><br> <button class="custom_specialcase">B2</button><br> <input type="checkbox" class="custom_specialcase"/>Checkbox1<br> <input type="checkbox" />Checkbox2<br> <input type="radio" class="custom_specialcase"/>Radio1<br> <input type="radio" />Radio2<br> <select class="custom_specialcase">Select <option>1</option> <option>1</option> </select> <select > <option>2</option> <option>2</option> </select> </div>I'm new to JQuery. I need to disable all from elements except with this class custom_specialcase.
Thanks
<div> <button>B1</button><br> <button class="custom_specialcase">B2</button><br> <input type="checkbox" class="custom_specialcase"/>Checkbox1<br> <input type="checkbox" />Checkbox2<br> <input type="radio" class="custom_specialcase"/>Radio1<br> <input type="radio" />Radio2<br> <select class="custom_specialcase">Select <option>1</option> <option>1</option> </select> <select > <option>2</option> <option>2</option> </select> </div>最满意答案
您可以使用选择器"input, select, button"调用jQuery() ".custom_specialcase" .not()和选择器".custom_specialcase" ,。 ".custom_specialcase" .attr() ,将disabled属性设置为"disabled" at .ready()处理程序
$(function() { jQuery("input, select, button") .not(".custom_specialcase").attr("disabled", "disabled") })You can use selector "input, select, button" at call to jQuery(), .not() with selector ".custom_specialcase", .attr(), set disabled attribute to "disabled" at .ready() handler
$(function() { jQuery("input, select, button") .not(".custom_specialcase").attr("disabled", "disabled") })更多推荐
发布评论