Home > Web Front-end > JS Tutorial > Set events for html hyperlinks without using href to complete the jump_javascript skills

Set events for html hyperlinks without using href to complete the jump_javascript skills

WBOY
Release: 2016-05-16 16:51:54
Original
1181 people have browsed it

Sometimes, we need to use the hyperlink instead of using href to complete the jump, but like: jumps to the address pointed to by href again, and "#" is an anchor point, which defaults to the top of the web page, so it will cause the problems mentioned above.

There are two solutions:

1. Add a return false statement to the onClick event, for example:

Copy code The code is as follows:

2. Replace # with void(0), for example:
Copy the code The code is as follows:
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template