一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

zepto获取select元素的选中option例子

时间:2015-02-06 编辑:简简单单 来源:一聚教程网

zepto


在zepto中不能用,网上搜索了一番,找到了一个方法:

$(‘option’).not(function(){ return !this.selected });

这样就可以在zepto中获取到select中被选中的option。

补充知识点:

问题:$('option[selected]') only finds options that have their selected attr set in the html.It does not find values the the user has selected themselves.

jquery与js获得option值方法

javascript

var item = document.getElementById("");
var text = item.options[item.selectedIndex].text;

jQuery

var text = $("#selector")[0].options[$("#selector")[0].selectedIndex].text

热门栏目