Jquery 单击后,搜索书签并显示书签所在的div

Jquery 单击后,搜索书签并显示书签所在的div,jquery,Jquery,使用jQuery或其他方法可以实现这一点吗?基本上,我在屏幕上显示的div中有一个书签超链接。它链接到另一个未显示的div中的书签标记。当用户单击书签链接时,是否可以检测包含书签的div的属性并将该div显示设置为显示 <div class="cpecontent" id="content_2"> <h2><br /> <a name="0.1__Toc320283140"> </a> <a name="0.1__To

使用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>

顺便说一句,我认为这些链接称为锚而不是书签。

这段代码如何设置div以显示?您找到了书签,但是否可以检测到书签所在的div并显示该div?this.href包含整个URL,例如,“.”。有没有一种方法可以拆分上面的字符串?我刚刚发现链接也有一个哈希属性。this.hash.replace,另外,如果链接不是以开头,则必须使用包含选择器$'a[href*=]'
$('a[href^="#"]').click(function(){
    $('a[name="'+this.href.replace('#', '')+'"]').show();
});