Good day. I have a code <option value="63">1963</option>
How can I get "1963" then to display on the page?
alert(this.options[this.selectedIndex].innerHTML);
Updated
var selectTag = document.getElementById("yourIdForSelect");
selectTag.onchange = function(){
var selectedValue = this.options[this.selectedIndex].text; //returns 1963 when you select this option
// selectedValue contains the 1963
};
http://api.jquery.com/val/ there is a demo (first example) that does exactly what you are looking for.
html:
<select id="single">
<option>Single</option>
<option>Single2</option>
</select>
jquery (js):
var singleValues = $( "#single" ).val();
Try like this:
$('#lol').change(function(e){
var my_val = $(this).val();
if( my_val == "65" ) {
alert( $(this).find(':selected').text() );
}
});
live demo here http://jsfiddle.net/jogesh_pi/P3NNR/
html
<select id="select">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
jquery
$('#select option:selected').html();
OR
html
<option value="63" class="select">1963</option>
jquery
$('.select').html();
you can use the following js code to get the text of an option in select box
Js code
var text=$('#selectboxId').find('option[value=63]').text();
alert(text);