


The difference between html empty link href='#' and href='javascript:void(0)'
Note that it is the difference between jumping to the top of the page. It is better to use void(0) for better user experience.
#Contains a location information
The default anchor is #top, which is the top of the web page
And javascript:void(0) only represents a dead link
This is why sometimes The page is very long. The browsing link is obviously # but it jumps to the top of the page.
But javascript:void(0) is not the case.
So it is best to use void(0) when calling the script.
You can use the following example. Test it:
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> 这里是页首..... <p> </p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <p> 1</p> <a href="#">这是会跳到页首的</a> <a href="javascript:void(0)">这个不会跳动</a> </body> </html>
Tips: You can modify part of the code before running
# #
The above is the detailed content of The difference between html empty link href='#' and href='javascript:void(0)'. For more information, please follow other related articles on the PHP Chinese website!

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

Potential problems with using native select on mobile phones When developing mobile applications, we often encounter the need for selecting boxes. Normally, developers...

What are the disadvantages of using native select on your phone? When developing applications on mobile devices, it is very important to choose the right UI components. Many developers...

Use Three.js and Octree to optimize collision handling of third-person roaming in the room. Use Octree in Three.js to implement third-person roaming in the room and add collisions...

Issues with native select on mobile phones When developing applications on mobile devices, we often encounter scenarios where users need to make choices. Although native sel...

Exploring the implementation principle of mouse scrolling events When browsing some websites, you may notice that some page elements still allow scrolling the entire page when the mouse is hovering...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools
