获取select下的option的下标

<select name="selectType" id="selectIndex">
                <option>选择所属分类</option>
                <option>计算机/软件</option>
                <option>小说/文摘</option>
                <option>杂类</option>
            </select><br>
             <input type="button" value="获取值" id="getValue">
 $(function(){
        $('#getValue').click(function(){
       
            var select=document.getElementsByName("selectType")[0];
            var index=select.selectedIndex;
            alert(index)
        })
    })
发布了108 篇原创文章 · 获赞 46 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_44739706/article/details/104642752