首页
学习
活动
专区
工具
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...; // selectedIndex代表是你所选中index 3:拿到选中optionsvalue: myselect.options[index].value; 4:拿到选中options...); 二:jQuery方法 1:var options=$(“#select option:selected”); //获取选中 2:alert(options.val()); //拿到选中值...3:alert(options.text()); //拿到选中文本 4:alert(options.attr(‘url’)); //拿到选中url值 版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人

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