jQuery和 Zepto两者获取select的方法有所不同,记录如下:
jQuery
$('#testSelect option:selected').text();//选中的文本
$('#testSelect option:selected') .val();//选中的值
$("#testSelect ").get(0).selectedIndex;//索引
Zepto
$("select[name=provience] option").not(function(){ return !this.selected }).text();

本文详细对比了jQuery和Zepto在获取select元素的文本、值和索引时的不同方法,提供了两种库在实际开发中选择的依据。
1524

被折叠的 条评论
为什么被折叠?



