禁用除特定类之外的所有表单元素(Disable all form elements except particular class)

编程入门 行业动态 更新时间:2024-10-28 09:15:58
禁用除特定类之外的所有表单元素(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") })

更多推荐

本文发布于:2023-04-29 07:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335997.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   元素   Disable   class   elements

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!