Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

selected dropdown value

Plain JavaScript:
===================
var e = document.getElementById("elementId");
var value = e.options[e.selectedIndex].value;
var text = e.options[e.selectedIndex].text;
---------------------------------------------------------
jQuery:
=======
$("#elementId :selected").text(); // The text content of the selected option
$("#elementId :selected").val(); // The value of the selected option
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #selected #dropdown
ADD COMMENT
Topic
Name
4+1 =