select 对当前选项显示文本的获取 m.options[m.selectedIndex].text | selectz

select 对当前选项显示文本的获取 m.options[m.selectedIndex].text | selectz

<html>
  <head>
    <title>select</title>
  </head>
  <body>
    <select id="mySelect">
      <option value="volvo">Volvo111</option>
    <option value="saab">Saab111</option>
    <option value="mercedes">Mercedes111</option>
    <option value="audi">Audi111</option>
    </select>
    <script>
      function getSelect () {
        const m = document.getElementById('mySelect')
        console.info('m', m)
        console.info('m.value', m.value)
        console.info('m.text', m.text)
        console.info('m.name', m.name)
        console.info('m.innerText', m.innerText)
        console.info('m.selectedIndex ', m.selectedIndex )
        console.info('m.selectedIndex ', m.selectedIndex )
        console.info('m.options[m.selectedIndex].text', m.options[m.selectedIndex].text)
      }
    </script>
  </body>
</html>
posted @ 2023-11-21 08:56  彭成刚  阅读(20)  评论(0编辑  收藏  举报