내가 간단한 jQuery를 탭 설정을위한이 코드를 사용하고 있습니다 : 여기Jquery - 한 페이지에서 여러 탭으로 작업 하시겠습니까?
$('.tabs .tab_content').hide(); // Hide all divs
$('.tabs .tab_content:first').show(); // Show the first div
$('.tabs ul.tab_nav li:first').addClass('current_tab'); // Set the class of the first link to active
$('.tabs ul.tab_nav li a').click(function(){ //When any link is clicked
$('.tabs ul.tab_nav li a').removeClass('current_tab'); // Remove active class from all links
$(this).addClass('current_tab'); //Set clicked link class to active
var currentTab = $(this).attr('href'); // Set variable currentTab to value of href attribute of clicked link
$('.tabs .tab_content').hide(); // Hide all divs
$(currentTab).show(); // Show div with id equal to variable currentTab
return false;
});
그리고 것은 샘플 HTML입니다 :
<div class="box tabs">
<div class="box_header">
<h2>3/4 Width</h2>
<ul class="tab_nav">
<li><a href="#tab1" class="current_tab">Tab #1</a></li>
<li><a href="#tab2">Tab #2</a></li>
<li><a href="#tab3">Tab #3</a></li>
<li><a href="#tab4">Tab #4</a></li>
</ul>
</div>
<div class="box_content tab_content" id="tab1">1</div>
<div class="box_content tab_content" id="tab2">2</div>
<div class="box_content tab_content" id="tab3">3</div>
<div class="box_content tab_content" id="tab4">4</div>
</div>
그것은 탭 중 하나 개 세트 아름답게 작동하지만 다른 설정을 추가하는 경우 (위 코드와 같은 또 다른 코드 블록) 모두 엉망이되어 탭을 두 개의 개별 탭 인스턴스가 아닌 하나의 큰 객체로 취급합니다. 어떻게 작동하도록 변환 할 수 있습니까? 이상적으로 HTML에 많은/아무것도 추가하지 않고?
감사합니다. 당신이 tab_nav하고 탭을 사용하면 두 세트를 조작 tab_nav를 조작 변경 언제든지 주위에 당신의 솔루션을 구축하기 때문에 당신이있을 때
알렉스
가 [jQuery를 UI 탭]에서보세요이 코드를 사용해보십시오 (http://jqueryui.com/demos/tabs/) – noob