each
<select name="sel" id="selectstation"> <option value="1" id='first_options'>苹果</option> <option value="2">西瓜</option> <option value="3">无花果</option> <option value="4">艾叶果</option> <option value="5">清果</option> </select>
<h2>遍历获取option </h2> <input type="button" id="each" value='遍历获取option' />
1.通过each函数中下标 i 获取option值
$('#each').click(function(){
        str = '';
        $('#selectstation  option').each(function(i){
            str += $('#selectstation option:eq('+i+')').text()+',';
        });
        alert(str);
    });
2.通过this转化成jquery对象
    $('#each').click(function(){
        st = '';
        $('option').each(function(i){
            st += $(this).text();//this 表示的是dom对象
        });
        alert(st);
    });
3.使用原生js注意
//原生 this.value; this.text;
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号