开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜