jeudi 9 avril 2015

How to select value of dropdown using jQuery

I have a dropdown using boostrap. I need to store the value they select from the dropdown in a variable, but for now I'm just trying to print it.



window.alert($("#list_userInput_location option:selected").val());


It displays 'undefined'. If I do this:



window.alert($("#list_userInput_location option:selected").text());


It displays an empty string. Also tried this:



window.alert($("#list_userInput_location").val());


Displays 'undefined' again.


So confused.......... Any thoughts?





Aucun commentaire:

Enregistrer un commentaire