js select下拉框的值

xiaoxiao2021-02-28  51

window.onload=function(){ var oBtn=document.getElementById("btn"); var sel=document.getElementById("select"); oBtn.onclick=function(){ var index=sel.selectedIndex ; var val=sel.options[index].value; var txt= sel.options[index].text; console.log(index); console.log(val); console.log(txt); } }
转载请注明原文地址: https://www.6miu.com/read-66055.html

最新回复(0)