Saturday, July 17, 2010

Get Select Box Value - jQuery Tip

It is easy as 1,2,3 with jQuery :)

$('#selectbox').val()

Lets see how to write this with on change event

$('#selectbox').change(function(){
     alert($(this).val());
});

Lets see how to get the selected text (not the value)

$('#selectbox').change(function(){
     alert($('#selectbox :selected').text());
});

No comments:

Post a Comment