开发者

How to call a particular div using html hyperlink

I want to call a particular div using a hyperlink. Here is my code:

 <div id="mainNavPane">
    <ul id="sideSubNav">

        <li><a href="#" class="prim">Individuals</a></li>
        <li><a href="#" class="view">Individuals1</a></li>
    </ul>
</div>

<div id="mainScrollPane">

  <!-- 1-5 -->
  <div id="homeScreen" class="screen">
     <div class="arrowLeft" style="width:50px;"><a class="prev"><img src="../images/btn-ArrowPrev.gif"/></a></div&g开发者_StackOverflow中文版t;
    <img src="images/bg-HomeScreen.jpg" height=50px width=50px />
     <div class="arrowRight" style="width:50px;"><a class="next"><img src="../images/btn-ArrowNext.gif" /></a></div>
  </div>

   <!-- 5-10 -->
  <div id="IndividualsScreen" class="screen">
     <h2>Individuals using Breaking Free Online</h2>
     <div class="arrowLeft" style="width:50px;"><a class="prev"><img src="../images/btn-ArrowPrev.gif" /></a></div>
     <div class="screenBody" style="width:460px;">
      <ul>
          <li>If you are struggling to control your drinking or use of drugs, Breaking Free Online
              offers you treatment that is immediate, confidential and effective – even if your
              dependence is severe and has been for a long time </li>
          <li>You can take advantage of the treatment at home or anywhere with an internet connection,
              and at the times that are most convenient for you, because it is available online
              24 hours a day </li>
           </ul>
      </div>
      <div class="arrowRight" style="width:50px;"><a class="next"><img src="../images/btnArrowNext.gif" /></a></div>
  </div>   
    </div>

I want to display div id = individualscreen when <a href="#" class="prim">Individuals</a> hyperlink is clicked similarly when the <a href="#" class="view">Individuals1</a> should show div id=homescreen


Just use a # followed by the id of the element: href="#individualscreen"


If you want to navigate to the div, you can follow David Dorward's example.

If you want to hide/show the div when the link is clicked, you can do something like this:

$(function() {
  $('#prim').click(function(e) {
    e.preventDefault();
    $('#individualscreen').toggle();
  });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜