w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
jquery for select all item in multiple select list box

jQuery code:

You need to be using

$(this).prop('selected', true);

But if you still wanna use attr() then use this:

$(this).attr('selected', 'selected'); // your method is also OK!

Select multiple attribute:

P.S, please check that whether the select tag has the multiple attribute in it or not ;) since that might be the cause of the problem.

Since in this fiddle: http://jsfiddle.net/afzaal_ahmad_zeeshan/tusUA/1/ by Kevin, you can see the multiple attribute applied to the select and the code is working.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.