首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

JS操作表单select详解-选取当前值、重置option

JS操作表单select详解-选取当前值、重置option等 对于表单(form)中常用的select选项,经常牵涉到选取的option的index值、value值及文本中,本文结合着实例对其进行讲解。...一个select如下 pre option1 option2 option3 option4 option5 next 代码的效果图 select中常用的操作如下: 1.获取select对象; var...sel=document.querySelector(“#choose”); 2.获取select选中option的index值; var index=sel.selectedIndex; 3.获取select...选中的option的 value; var val=sel.options[index].value; 4.获取select选中的option的text; var text=sel.options[index...].text; JS代码实现 let sel = document.querySelector('#choose'); let selarr = [...sel]; let selarrLength

27810
领券