2012-06-06 6 views
0

jQuery 또는 다른 방법으로 가능합니까? 기본적으로, 화면에 표시되는 div에 북마크 하이퍼 링크가 있습니다. 표시되지 않는 다른 div의 북마크 태그에 연결됩니다. 사용자가 북마크 링크를 클릭하면 북마크가 포함 된 div의 속성을 감지하고 표시 할 div 표시를 설정할 수 있습니까?클릭하면 북마크가 검색되고 북마크가 표시됩니다.

<div class="cpecontent" id="content_2"> 
    <h2><br /> 
    <a name="0.1__Toc320283140"> </a> <a name="0.1__Toc325358918"> </a>Determine All Sources of Income (Taxable and Non-Taxable)</h2> 
    <p><br /> 
    Reaching into the bag you pull out an amorphous jumble of paper. There are receipts, a stapled stack of credit card statements, a few 1099s, a W-2, a manila envelope labeled "investments," some check stubs, and one artificial fingernail. "What is all this?" you inquire. </p> 
    <p><br /> 
    "Monday nights at 6:15. It's all about the lottery and I play a woman who runs this magical machine that grabs numbered ping pong balls. It's like a big popcorn machine. My character presses a button that makes the machine grab a ball out of the air. When the machine grabs a ball, she has to turn it so the number faces the camera. There's no dialogue yet, but my manager says they're probably going to expand my role." </p> 
    <p><br /> 
    <!--ON Click for this Bookmark, set the div below to display:show;--> 
    <a href="#0.1__Gross_Income" title="_Gross_Income"> <span> For more on this topics - see Appendix A </a> </p> 
</div> 


<!--A LOT OF CONTENT IN BETWEEN--> 

<!--This DIV is hidden right now, but we want to try and show it--> 
<div class="cpecontent" id="content_11" style="display:none;"> 
    <h2><br /> 
    <a name="0.1__Toc325358937"> </a> <a name="0.1__Gross_Income"> </a>Gross Income</h2> 
    <p><br /> 
    All of the following constitute possible sources of Gross Income:</p> 
    <p style="margin-bottom:0pt;line-height:12pt">Wages</p> 
    <p style="margin-bottom:0pt;line-height:12pt">Self-employment income</p> 
    <p style="margin-bottom:0pt;line-height:12pt">Partnership and S corporation income</p> 
</div> 

답변

0
$('a[href^="#"]').click(function(){ 
    $('a[name="'+this.href.replace('#', '')+'"]').show(); 
}); 

은 BTW 나는 그 링크가 앵커하지 북마크이라고 생각합니다.

+0

이 코드는 div가 표시되도록 어떻게 설정합니까? 북마크를 찾았지만 북마크가있는 div를 감지하고 해당 div를 표시 할 수 있습니까? – user988256

+0

당신은') .parents ('div')가 필요하다고 생각합니다. show();' – romo

+0

this.href가 전체 URL과 연결됩니다 (예 : 'http://domain.com/index-page- 계속 - 전문 교육 - 서브 페이지 - 디스플레이 코스 - 27.htm # 0.1__Gross_Income. #에 문자열을 분할하는 방법이 있습니까? – user988256

관련 문제