저는 데이터를 처리하기 위해 많은 div와 javascript가있는 대시 보드를 만들고 있습니다. 나는 탭을 기반으로 콘텐츠를 구성하는 것을 좋아합니다. 탭을 클릭하면 javascript로 처리되는 특정 정보를 표시하고 싶습니다.비활성 탭에서 데이터를 어떻게 비 웁니 까?
<script>
// Wait until the DOM has loaded before querying the document
$(document).ready(function(){
$('ul.tabs').each(function(){
// For each set of tabs, we want to keep track of
// which tab is active and it's associated content
var $active, $content, $links = $(this).find('a');
// If the location.hash matches one of the links, use that as the active tab.
// If no match is found, use the first link as the initial active tab.
$active = $($links.filter('[href="'+location.hash+'"]')[0] || $links[0]);
$active.addClass('active');
$content = $($active.attr('href'));
// Hide the remaining content
$links.not($active).each(function() {
$($(this).attr('href')).hide();
});
// Bind the click event handler
$(this).on('click', 'a', function(e){
// Make the old tab inactive.
$active.removeClass('active');
$content.hide();
// Update the variables with the new link and content
$active = $(this);
$content = $($(this).attr('href'));
// Make the tab active.
$active.addClass('active');
$content.show();
// Prevent the anchor's default click action
e.preventDefault();
});
});
});
</script>
:
이것은가 탭 선택을위한 스크립트입니다 : 많은 데이터가있을 것이기 때문에, 나는 탭에서만 정보 (가) 포함을 표시하고 32 파괴/클릭 탭 이외 비워 싶습니다
이것은 탭의 thml입니다. 홈 탭을 클릭하면 홈 탭의 데이터가 표시되어야합니다. 나는 다른 divs에있는 모든 다른 데이터를 eptied하거나 파괴해야합니다. 어떻게하면 좋을까요?
<ul class='tabs'>
<li><a href='#tab1'>HOME</a></li>
<li><a href='#tab2'>it</a></li>
<li><a href='#tab3'>markting</a></li>
<li><a href='#tab4'>finance</a></li>
<li><a href='#tab5'>accounting</a></li>
<li><a href='#tab6'>pr</a></li>
</ul>
<div id='tab1'>
<div id="container">
<table align="center">
<tr>
<td><div id="web1_cpu" class="chart" style="width:500px; height:250px;"></div></td>
<td><div id="web2_cpu" class="chart" style="width:500px; height:250px;"></div></td>
</tr>
</table>
<table align="center">
<tr>
<td><div id="site1_cpu" class="chart" style="width:500px; height:250px;"></div></td>
<td><div id="site2_cpu" class="chart" style="width:500px; height:250px;"></div></td>
</tr>
</table>
<table align="center">
<tr>
<td><div id="app1_cpu" class="chart" style="width:500px; height:250px;"></div></td>
<td><div id="app2_cpu" class="chart" style="width:500px; height:250px;"></div></td>
</tr>
</table>
</div>
</div>
를? 실제로 프로세스를 추가하기 때문에 성능이 향상되지 않고 어쨌든 숨겨집니다. – isherwood
@isherwood, 각 탭에는 여러 개의 div가 있고 각 div에는 많은 양의 데이터가있는 차트가 있습니다. 선택한 각 탭 아래에 데이터 만 표시하고 다른 탭의 다른 데이터는 모두 삭제하는 것을 좋아합니다. 이 작업을 수행하지 않으면 브라우저에서 메모리가 부족해져 충돌이 발생합니다. – user1471980