Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable multiple listboxes in one go using jQuery?

Tags:

jquery

listbox

I can disable one and one by doing this:

jQuery('#ListBoxA').attr('disabled','true');

But how can I apply this to multiple items? This does not work:

jQuery('#ListBoxA, #ListBoxB, #ListBoxC').attr('disabled','true');

UPDATE

Not much markup to show....

<select id="ListBoxA" size="4" name="countrySelectBox">
<select id="ListBoxB" size="4" name="cityListBox">
<select id="ListBoxC" size="4" name="storeListBox" multiple="multiple">
like image 371
Steven Avatar asked Dec 23 '22 08:12

Steven


1 Answers

jQuery('#ListBoxA,#ListBoxB,#ListBoxC').attr('disabled','disabled'); (Without white spaces).

To enable use jQuery('#ListBoxA,#ListBoxB,#ListBoxC').removeAttr('disabled');

http://docs.jquery.com/Selectors/multiple#selector1selector2selectorN

like image 65
Cesar Avatar answered Feb 01 '23 23:02

Cesar