zepto 獲取select選中的值

jQuery中典型的方法:javascript

$('option[selected]')

無論用,由於selected並非CSS標準。
 
所以,在zepto中想要獲取select元素中選中的option,需採起以下方法:
// get OPTION elements for which `selected` property is true
$('option').not(function(){ return !this.selected })

或者推薦java

 $("#ID").val() //獲取選中的value   git

$("#ID option").eq($("#ID").attr("selectedIndex")).text() //獲取選中的文本值  github

參考資料:https://github.com/madrobby/zepto/issues/503this

相關文章
相關標籤/搜索