Home  >  Article  >  Web Front-end  >  Summarize the usage of anchor points in html and js

Summarize the usage of anchor points in html and js

巴扎黑
巴扎黑Original
2017-06-01 16:22:481989browse

Usage of anchor points in HTML:

1.Detailed explanation of what html anchor points are

The first step in learning web page knowledge must be HTML, among which html anchors What exactly is the point for?

To put it simply, for example, if you want to read a very long article accurately by segment, you can use anchor points.

Summarize the usage of anchor points in html and js

2.htmlAnchor point usage example

After understanding what an anchor point is, let’s learn how to use it. .

Summarize the usage of anchor points in html and js

Instances of using anchor points in js:

1.js method of locating an anchor point

html page can set anchor points, anchor point definition

Summarize the usage of anchor points in html and js

2.js implements the index sliding display effect and sliding display anchor point effect of the address book

The first one is to slide on the index bar on the right side of the address book. When you slide to the corresponding letter, it will jump to the anchor point of the corresponding letter.

Idea: Listen to the touchmove event, obtain clientX and clientY, pass them to elementFromPoint, and then execute click() after obtaining the element.

Summarize the usage of anchor points in html and js

3.Javascript implementation example of navigation anchor scrolling effect

There may be such a requirement in common development pages, the page There will be multiple modules in the module, and each module corresponds to a navigation. When the page scrolls to a certain module, the corresponding module navigation needs to add a class to distinguish the area browsed by the current user.

Summarize the usage of anchor points in html and js

Anchor related questions and answers:

1.javascript - angular anchor question

2.angular.js - AngularJs controls page output by defining anchor links

3.html5 - Anchor problem of a tag in HTML

The above is the detailed content of Summarize the usage of anchor points in html and js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn