Get the selected value when changing the selected value with jQuery
I'd like when I selected a value in a dropdown get the value selected.开发者_高级运维
Any idea ?
Thanks,
Try something like this:
$(document).ready( function(){
$('#your_select').change( function(){
var result = $(this).val();
do_something_with(result);
});
});
Assuming HTML like this:
<select id="your_select" name="selectname">
<option value="foo">Foo!</option>
<option value="bar">Bar!</option>
</select>
$('select').change(function() {
alert($(this).val());
});
JSFiddle Example
精彩评论