Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  53] [ 3]  / answers: 1 / hits: 189445  / 12 Years ago, thu, march 29, 2012, 12:00:00

This is my HTML



<select name=countries id=countries MULTIPLE size=8>
<option value=UK>UK</option>
<option value=US>US</option>
<option value=Canada>Canada</option>
<option value=France>France</option>
<option value=India>India</option>
<option value=China>China</option>
</select>
<br />
<input type=button id=select_all name=select_all value=Select All>


When user click on 'Select All' button, I want all the options in the select box to be selected



$('#select_all').click( function() {
// ?
});

More From » jquery

 Answers
49

Try this:



$('#select_all').click(function() {
$('#countries option').prop('selected', true);
});


And here's a live demo.


[#86537] Wednesday, March 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
benitoh

Total Points: 150
Total Questions: 113
Total Answers: 104

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
benitoh questions
Sun, Mar 21, 21, 00:00, 3 Years ago
Mon, May 13, 19, 00:00, 5 Years ago
;