jQuery를 사용하여 페이지의 섹션을 표시하거나 숨 깁니다. 이 접근 방식은 Chrome, FF 및 Safari에서 작동하지만 IE8 및 7에서는 중단됩니다. 애니메이션, 페이드 및 불투명도를 사용하여 시도했습니다. IE에서 아무것도 작동하지 않는 것 같습니다. IE Developer Tools의 js 콘솔에 따르면 선택된 요소에 '활성'클래스가 있지만 Dev Tools HTML 창에서 dom 트리를 보면 활성 클래스가 DOM에 제거되거나 다시 작성되지 않았습니다. .IE8 이하에서 jQuery 클래스를 추가/제거 할 수 없습니다.
마크 업
<nav>
<ul>
<li id="foo">Show Section 1</li>
<li id="bar">Show Section 2</li>
</ul>
</nav>
<div id="items">
<section class="foo">Content Section 1</section>
<section class="bar">Content Section 2</section>
</div>
CSS의
#items > section {display: none;}
.active {display: block;}
어떤 조언을 크게 평가되는 JS
$('nav li').click(function(){
var $me = $(this);
showSection($me.attr('id'));
});
showSection function(whichSection){
$('#items > section').removeClass('active');
$('#items > '+'.'+whichSection).addClass('active');
}
. 나는 심한 기한을 넘기고있다. 건배.
IE8에 HTML5 태그를 인식 시키려면 html5shiv (또는 Modernizr)를 포함해야 할 수도 있습니다. – Adam
귀하의 HTML이 유효성을 검사합니까? 또한 아담의 의견을 참조하십시오. – Sparky
예제가 어디에서 어떻게 작동하는지 알 수 없습니다. – j08691