2011-08-09 2 views
0

라디오를 클릭 할 때마다 HTML 코드를 표시 할 때이 방법이 옳다고 생각하십니까?
HTML 코드 표시 및 숨기기에 적합한 애니메이션 효과 (효과)를 제안 하시겠습니까? 관련하여 http://jsfiddle.net/9LECb/
jQuery 여러 라디오 버튼과로드 HTML 코드?

$('#housing_select input').click(function(){ 
     var classes = $(this).attr('id'); 
     if(classes == 'hotel_select'){ 
      $('.hotel_apartment_select, .suite_select').hide(); 
      $('.'+classes).show(); 
     } 
     if(classes == 'hotel_apartment_select'){ 
      $('.hotel_select, .suite_select').hide(); 
      $('.'+classes).show(); 
     } 
     if(classes == 'suite_select'){ 
      $('.hotel_select, .hotel_apartment_select').hide(); 
      $('.'+classes).show(); 
     } 
    }) 

답변

0

당신은 조건 경우 제거에 코드를 최소화 할 수 있습니다 :

$('#housing_select input').click(function() { 
    var classes = $("." + this.id); 

    $('.hotel_apartment_select, .suite_select, .hotel_select').not(classes).hide(); 
    classes.show(); 
}) 

JSFiddle : http://jsfiddle.net/9LECb/2/
당신에게 내 코드의 예를 참조하십시오
jQuery UI Tabs과 비슷한 전자 메일을 확인할 수 있습니다. ffect

+0

JSFiddle를? -> this not update –

+0

@Sheikhasa : jsfiddle을 저장하지 않았습니다. 답변을 업데이트했습니다. 확인해 봐 – Chandu

0

이 시도 :

$('#housing_select input').click(function() { 
    $('.hotel_apartment_select, .suite_select, .hotel_select').not("." + this.id).hide(); 
    $("." + this.id).show(); 
})