Saturday, December 4, 2010

How do you get the current value from a select list usig JQUERY

To get the current value is very simple using val() .

$('#selectList').val();

But sometimes you may need to get the selected option’s text. This is not as straight forward. First, we get the selected option with :selected selector. Then once we have the option, we can get the text with the function,text().

$$('#selectList :selected').text();

No comments:

Post a Comment