Home>Article>Web Front-end> How to prevent a tag from jumping in css
Method: 1. Use "//m.sbmmt.com/m/faq/#", the syntax is "a href="//m.sbmmt.com/m/faq/#""; 2. Use "javascript:", the syntax is "a href="javascript:void(0)""; 3. Use getElementById to get the a tag, and use "return false;" to cancel the jump.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
百度
1. Let’s do the simplest thing first. We can add the # sign directly to the html code, as follows:
百度
2. Secondly, we The default event that blocks it is also the following:
百度
3. There is also our js method to block it. We still give the a tag an id. We only need to do the following Operation:
百度
let div1 = document.getElementById("Header1_HeaderTitle"); div1.onclick = function(){ return false; }
Recommended learning:css video tutorial
The above is the detailed content of How to prevent a tag from jumping in css. For more information, please follow other related articles on the PHP Chinese website!