天天看點

Zepto和jQuery擷取select元素的選中值的文本

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();
      

繼續閱讀