After the click event of html hyperlink a, jump to the address pointed to by href

After the click event of html hyperlink a, jump to the address pointed to by href
Sometimes, we need to use the hyperlink <a> instead of href to complete the jump, but instead use this method: <a href="#" onClick="fun()"></a>. This way, the page will not jump. But it also brings some negative problems, such as the page title becomes "#", or a scroll bar appears on the page. This is because after the onClick event is executed, <a> jumps to the address pointed to by href, and "#" is an anchor point, which defaults to the top of the web page, so it will cause the problem mentioned above.

There are two solutions:

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

<a href="#" onClick="fun(); return false;">Click</a>

2. Use void(0) instead of #, for example:

<a href="javascript:void(0)" onclick="fun()">Click</a>

<<:  MySQL series 15 MySQL common configuration and performance stress test

>>:  A few front-end practice summaries of Alipay's new homepage

Recommend

Getting Started Guide to MySQL Sharding

Preface Relational databases are more likely to b...

18 sets of exquisite Apple-style free icon materials to share

Apple Mug Icons and Extras HD StorageBox – add on...

mysql5.6.zip format compressed version installation graphic tutorial

Preface: MySQL is a relational database managemen...

Minimalistic website design examples

Web Application Class 1. DownForEveryoneOrJustMe ...

MySQL DeadLock troubleshooting full process record

【author】 Liu Bo: Senior Database Manager at Ctrip...

How to configure the My.ini file when installing MySQL5.6.17 database

I recently used the MySql database when developin...

Detailed explanation of the usage and difference between nohup and & in Linux

Example: We use the Python code loop_hello.py as ...

Use xshell to connect to the Linux server

Benefits of using xshell to connect to Linux We c...

Solve the problem of setting Chinese language pack for Docker container

If you use docker search centos in Docker Use doc...

Vue keeps the user logged in (various token storage methods)

Table of contents How to set cookies Disadvantage...

Detailed explanation of the misunderstanding between MySQL and Oracle

Table of contents Essential Difference Database s...

Analysis of the differences between Iframe and FRAME

1. Use of Iframe tag <br />When it comes to ...

Detailed explanation of the pitfalls of nginx proxy socket.io service

Table of contents Nginx proxies two socket.io ser...

Convert psd cut image to div+css format

PSD to div css web page cutting example Step 1: F...

Difference between HTML ReadOnly and Enabled

The TextBox with the ReadOnly attribute will be di...