X

Jquery: dropdown.val(‘selected’, ‘selected’) does not work anymore.

jquery

Was debugging some code that was broken due to jquery 1.6 update, and found this call for Jquery dropdown.val

$("#dropDownSelect option[text=" + myText +"]").attr("selected","selected") ;

Not working anymore but a simple fix of changing it to

$("#dropDownSelect option[text=" + myText +"]").prop("selected",true) ;

This does the trick, for more on prop take a look at the api of jquery http://api.jquery.com/prop/

Categories: JQuery
Taswar Bhatti: