使用jQuery获取下拉列表中选择的当前值 [英] Get current value selected in dropdown using jQuery
本文介绍了使用jQuery获取下拉列表中选择的当前值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面上有一组动态生成的下拉框.基本上,我使用jQuery克隆它们.现在我想捕获在每次更改事件下拉列表中选择的值.
I have a set of dynamically generated dropdown boxes on my page. basically I clone them using jQuery. now I want to capture the value selected on each dropdown on change event.
我尝试了类似的方法,但没有用.
I tried something like this which did not work.
$('._someDropDown').live('change', function(e) {
//debugger;
var v = $(this);
alert($(this + ':selected').val());
alert($(this).val());
});
如何完成?
推荐答案
这就是您所需要的:)
$('._someDropDown').live('change', function(e) {
console.log(e.target.options[e.target.selectedIndex].text);
});
对于新的jQuery,请使用on
For new jQuery use on
$(document).on('change', '._someDropDown', function(e) {
console.log(this.options[e.target.selectedIndex].text);
});
这篇关于使用jQuery获取下拉列表中选择的当前值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文