首頁  >  文章  >  web前端  >  jQuery或Js取得select選取的value或text

jQuery或Js取得select選取的value或text

巴扎黑
巴扎黑原創
2016-11-25 14:04:271580瀏覽

jquery 
取得文字值$("#select1  option:selected").text(); 
取得value值$("#select1  option:selected").val(); 

js
getElementById(”selectId”); //定位id 

var index = obj.selectedIndex; // 選取索引 
取得文字值 
var text = obj.options[index].text; // 選取文字 
var text = obj.options[index].text; // 選取文字 var value = obj.options[index].value; 

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn