jQueryのSelect操作セット

1598 ワード

jQuery  Select   Text Value: 
    : 
1. $("#select_id").change(function(){//code...});    // Select    ,           
2. var checkText=$("#select_id").find("option:selected").text();   //  Select   Text 
3. var checkValue=$("#select_id").val();   //  Select   Value 
4. var checkIndex=$("#select_id ").get(0).selectedIndex;   //  Select       

5. var maxIndex=$("#select_id option:last").attr("index");   //  Select      

jQuery  Select   Text Value: 
    : 
1. $("#select_id ").get(0).selectedIndex=1;   //  Select    1     
2. $("#select_id ").val(4);    //  Select Value  4     
3. $("#select_id option[text='jQuery']").attr("selected", true);    //  Select Text  jQuery     


jQuery  /  Select Option : 
    : 
1. $("#select_id").append("<option value='Value'>Text</option>");   // Select    Option(   ) 
2. $("#select_id").prepend("<option value='0'>   </option>");   // Select    Option(     ) 
3. $("#select_id option:last").remove();   //  Select      Option(    ) 
4. $("#select_id option[index='0']").remove();   //  Select     0 Option(   ) 
5. $("#select_id option[value='3']").remove();   //  Select Value='3' Option 
5. $("#select_id option[text='4']").remove();   //  Select Text='4' Option