简体   繁体   中英

page jump from div to an anchor

I was trying to make a div jump from <a href="#FAQ">FAQ</a> to a div id and could success easily, but since I have a fixed link to jump to, I can't seem to find a way how to do that.

Meaning, I want a div or a href link to jump to a url in the same page say <a href="http://www.mydomain.ask.html">Ask</a>

I know for sure that jumping from an anchor such as <a href="#jump">jump</a> to a div such as <div id="jump">jump to point</div> works fine. However, how about the opposite way? does it work? I mean jumping from div id to an anchor works?

As long as your anchor has an ID you can link to a location in your view by clicking the div you will just need some javascript.

Setting the window.location.hash value will put the focus of the view on the selected ID.

Sample

<a href="#test1" id="back">Test</a>

<div id="test1" onclick="window.location.hash='back'; ">

JSFiddle Example

我想你必须在你的第一个div中添加<a href="yourid">page place</a>并且必须为你的锚标签<a href="yourplace" id="idname"></a>

if you have link to go another with variable you can use with id # sign

<a href="product.php?action=edit#lastdiv>Go to Product Last Div</a>

<div id="lastdiv">There are last product Exist</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM