, 난 단지 당신이 렇게 할 생각 달성 jQuery를 충분히 잘 미안 알고있다. 아마도 의사 코드가 도움이 될지도 모른다. 하위 메뉴를 만들 때 사용한 html을 게시하면 도움이됩니다.
이 샘플은 nav 요소를 페이지의 개체와 간단히 연결합니다. (바람직하게는 모든 페이지에 링크 외부의 .js 파일)
스크립트 :
내가 팀 프로젝트를 위해 이것을 파악했다
//after you've set all sub-menus to display:none
//for each nav element
$('#nav a').each(function(){ //just like a for loop
var a,b;
// set a equal to the contents of the current nav element in the loop
a =$(this).html();
//set b equal to the contents of the first <h2> element on the current page
//or to whatever you want to use to distinguish as "a match" (needs not be visible)
b =$('h2:first').html();
//if the match is made... in this case, an exact match
if(a == b){
//Here you would have your display children code
//or display D and E or F and G code, depending on how you've set it up
}else //code to execute if no match is made
});
... 나는 많이도 배울 수 있어요. 그것을 좋아하십시오
감사합니다. 도움을 주셔서 감사합니다. –
문제가없는 사람, 당신의 학습에 행운을 비네! – subhaze