2

I'm a beginner and I'm wondering if there is a way to remove multiple attributes once without coding for each one.

For an example, please look at my code sample below.

$(".select-us").attr("disabled",true);
$(".select-as").attr("disabled",true);
$(".select-eu").attr("disabled",true);
$(".select-oc").attr("disabled",true);

I just want to know if there is any simpler way to do this. Thanks for your time.

Berglund
  • 636
  • 2
  • 7
  • 20

3 Answers3

2
$(".select-us, .select-as, .select-eu, .select-oc").attr("disabled", true);
Conor Heena
  • 86
  • 1
  • 2
  • 13
1

Please wrap your multiple form elements in fieldset and disable/ enable this only

<fieldset id='fset' disabled={true}>
...

can disable and enable with jquery like this

$("#fset").attr('disabled', true)
1

Add a new class to every element like "select-all" and do:

       $(".select-all").attr("disabled",true);
bill.gates
  • 14,145
  • 3
  • 19
  • 47