Go to #div JavaScript field

Maybe jQuery, maybe not, but how to do it, for example, when you click the link. Frequently asked questions can be found in the section "Questions and Answers"? I mean, if it's at the bottom, then you just click on this link and then it goes to it.

Wikipedia is. http://en.wikipedia.org/wiki/USA Links to the "Content" .. when you click, you get to it.

+4
source share
2 answers

This is not Javascript, these are anchor links. See: http://www.w3.org/TR/html401/struct/links.html

Basically, you would indicate as such:

<a href="#FAQ">FAQ</a> 

Then, over the content you are linking to:

 <a name="FAQ" /> 

Alternatively, you can use the same link and set the identifier of the header of the FAQ section to “FAQ”, for example:

 <h1 id="FAQ">FAQs</h1> 
+11
source

First add id to the HTML element. This will serve as an anchor.

For instance:

 id="mybox" 

Now just add the link to #mybox on this page. For instance. example.com/index.html#mybox

 <a href="#mybox">Box</a> 

As already mentioned, they have nothing to do with javascript; it is not required for this.

+5
source

Source: https://habr.com/ru/post/1301156/


All Articles