0
点赞
收藏
分享

微信扫一扫

下拉列表

玉字璧 2022-08-31 阅读 64

<select id="test"  name="">   
<option value="1">text1</option>
<option value="2">text2</option>
</select>



js如何获取下拉列表选中的值:
1、      拿到selected对象:var obj=document.getElementById("#test");
           拿到选中的索引:  var index=obj.selectedIndex;
 拿到选中项options的value: obj.options[index].value;
 拿到选中项options的text  :obj.options[index].text;

jquery如何获取下拉列表selecte的值:
$('select option:selected').val()
$('select option:selected').text()



js、jQuery 关于下拉框 取值操作​

举报

相关推荐

0 条评论