10 09/2014

jquery select get selected index

最后更新: Wed Sep 10 2014 12:37:50 GMT+0800

jquery select get selected index

<select>
    <option>111</option>    
    <option>2222</option>    
    <option>3333</option>    
    <option>444</option>    
    <option>5555</option>    
</select>
<script type="text/javascript">
$(function(){
    $('select').change(function(){
        console.log($(this).prop('selectedIndex'))
        console.log($(this)[0].selectedIndex)
    })
})    
</script>

jquery select get selected option text

$("#myselect option:selected" ).text();
$("#list option[value='2']").text()