select 상자의 값과 부여에 대한 jquery 설명

2564 단어 jquery
jQuery("#select_id").change(function(){}); // 1. Select    ,               

var checkValue = jQuery("#select_id").val(); // 2.  Select    Value  

var checkText = jQuery("#select_id :selected").text(); // 3.  Select    Text   

var checkIndex = jQuery("#select_id").attr("selectedIndex");// 4.  Select       ,

  :jQuery("#select_id").get(0).selectedIndex;  

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

  :jQuery("#select_id :last").get(0).index;



 

jQuery("#select_id").get(0).selectedIndex = 1; // 1.  Select    1      

jQuery("#select_id").val(4);  // 2.  Select Value  4    

$("#select_id").attr("value","Normal“);

$("#select_id").get(0).value = value;

//  select      select  

var count=$("#select_id").get(0).options.length;

for(var i=0;i<count;i++){

if($("#select_id").get(0).options[i].text == text)  

{

$("#select_id").get(0).options[i].selected = true;          

break;  

}  

}



 

jQuery("#select_id").append("<option value='  '>  option</option>"); // 1. Select    Option(   )   

jQuery("#select_id").prepend("<option value='   '>   </option>"); // 2. Select    Option(     )  

jQuery("#select_id").get(0).remove(1);  // 3.  Select     1 Option(   )  

jQuery("#select_id :last").remove();  // 4.  Select      Option(    )   

jQuery("#select_id [value='3']").remove(); // 5.  Select Value='3' Option   

jQuery("#select_id").empty();   // 6.        

좋은 웹페이지 즐겨찾기