select box 컨트롤 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

select box 컨트롤 정보

jQuery select box 컨트롤

본문

// [ select box 컨트롤 ] --------------------------------------------------------------/// 

// 셀렉트박스 초기화        
//SelectBox 애완동물중 고양이 값 선택하기.
$("#ANI").val('2');
$("#ANI>option[value='2']").attr("selected", true);
//또는 옵션그룹이 있는Select Box 인경우
$("#ANI> optgroup >option[value='2']").attr("selected", true);
 
//선택된 값 읽어오기
$("#ANI option:selected").val();
$("select[name=ANI]").val();
 
//선택된 값 삭제
$('#ANI option:selected').remove();
 
//SelectBox 애완동물중 고양이 삭제
$("#ANI option[value='2']").remove();    
  
jQuery("#ElementID").is(":checked")
 
if(jQuery("#ElementID").is(":checked"))  
{
     체크된 상태
}
else
{
    체크가 해제된 상태
}
 
select box의 내용 가져오기
$("#select_box > option:selected").val();
select box의 값 설정
 $("#select_box > option[value=지정값]").attr("selected", "true");

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로