js获取select option中的值或者value值

    xiaoxiao2023-12-02  129

    <!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> </head> <body> <select id="sel" onchange="cge()"> <option value="1">4</option> <option value="2">5</option> <option value="3">6</option> </select> </body> <script> function cge(){ var sel=document.getElementById('sel'); var sid=sel.selectedIndex; alert('value值:'+sel[sid].value+',option值:'+sel[sid].innerHTML); } </script> </html>

     

    最新回复(0)