Srinivas Sarda Srinivas Sarda - 1 year ago 74
jQuery Question

Disable all form elements except particular class

I'm new to JQuery.
I need to disable all from elements except with this class custom_specialcase.


<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
<select >

Answer Source

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")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download