select选中option触发事件

    <select id="selectId">

        <option value="a">选项一</a>
        <option value="b">选项二</a>
        <option value="b">选项三</a>

    </select>

    <script type="text/JavaScript">
        var selectId = document.getElementById("selectId");//获取ID
        selectId.onchange = function()//触发事件
        {
            var result = selectId.options[selectId.selectedIndex].innerHTML;//获取选中文本
            alert(result);
        }
    </script>

猜你喜欢

转载自blog.csdn.net/csdnlinyongsheng/article/details/81186294