首页
学习
活动
专区
工具
TVP
发布

js:如何获取select选中

我想获取select选中value,或者text,或者…… 比如这个: <option value=”A” url=”http://www.baidu.com...JavaScript原生方法 1:拿到select对象: `var myselect=document.getElementById(“select”); 2:拿到选中索引:var index=myselect.selectedIndex...text: myselect.options[index].text; 5:拿到选中其他,比如这里url: myselect.options[index].getAttribute(‘url’...); 二:jQuery方法 1:var options=$(“#select option:selected”); //获取选中项 2:alert(options.val()); //拿到选中...3:alert(options.text()); //拿到选中文本 4:alert(options.attr(‘url’)); //拿到选中url 版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人

25.5K30
您找到你想要的搜索结果了吗?
是的
没有找到
领券