HTML anchor Click to jump to the specified location on the page.

Source: Internet
Author: User

Originally was looking at Nandashin write Ajax tutorial, suddenly found that clicking on the directory text will jump to the corresponding text content, thus stimulated my interest.

This exactly how to do, just start to look at the time of smattering, find Niang is: "Click to jump to the page to specify the location", looked for the next, the original professional terminology called: Anchor point.

Degree Niang is really a profound place, has a variety of methods can be used.

One of the simplest:

Set the anchor point of a tag on the line, but there is a certain link will change, not conducive to refreshing

<divclass="Skip"Id="Skip"> "#toc0" class="AAA"> Click the text to jump </a> <!--The value of the Herf must be with the # number and match the value that corresponds to the jump-</li> </ul> <divclass="Chapter"style="margin-top:850px;"> <a name="toc0" class="Aaa1"> Text jump to Here </a> <!--The A tag here can also be used with the name id--> <p>mood false mood fake mood false mood false mood false mood fake mood false mood false mood false mood false mood fake mood false mood false mood fake mood false mood false mood fake mood false mood fake mood leave</p> </div></div>

The second method is to move according to the method of animate

Animate (params, [Duration], [easing], [Callback])

Create custom animations, note: All specified properties must be in camel form, such as marginleft instead of Margin-left.

Example:

//apply three types of effects in one animation at the same time$("#go"). Click (function () {$ ("#block"). Animate ({width:"90%", Height:"100%", FontSize:"10em",//Hump borderWidth:Ten  },  + );});

Remove the a tag from the HTML above #toc0

JS Code

$ (". AAA"). Click (function () {    $ ('html,body' ). Animate ({        scrolltop:$ (". Aaa1"). Offset (). Top},{duration:  easing:'swing'});     return false ;})

The above summary of the two are commonly used and compatible with the relatively good, relatively simple

can also refer to a complex case

Http://www.jb51.net/article/96574.htm

Http://bbs.csdn.net/topics/390960199?page=1

HTML anchor Click to jump to the specified location on the page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.