欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript獲取select標(biāo)簽選中的值

 更新時(shí)間:2016年06月04日 15:24:28   作者:cg_program  
這篇文章主要介紹javascript獲取select標(biāo)簽選中的值方法,比較實(shí)用,需要的朋友可以參考下。

復(fù)制代碼 代碼如下:
var obj = document.getElementById("testSelect"); //定位id
var index = obj.selectedIndex; // 選中索引
var text = obj.options[index].text; // 選中文本
var value = obj.options[index].value; // 選中值

jQuery中獲得選中select值

第一種方式

復(fù)制代碼 代碼如下:
$('#testSelect option:selected').text();//選中的文本
$('#testSelect option:selected').val();//選中的值
$("#testSelect").get(0).selectedIndex;//索引

第二種方式

復(fù)制代碼 代碼如下:
$("#tesetSelect").find("option:selected").text();//選中的文本
$("#tesetSelect").find("option:selected").val();
$("#tesetSelect").find("option:selected").get(0).selectedIndex;

以上就是javascript獲取select標(biāo)簽選中的值的全部內(nèi)容,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論