JS to click the link to cancel the jump effect

  • 2020-03-30 01:29:30
  • OfStack

<!DOCTYPE html> 
<meta charset="utf-8"> 
<meta name="author" content="//www.jb51.net/" /> 
<title> The home of the script </title> 
<script type="text/javascript"> 
  var olink=document.getElementById("link"); 
    if(confirm(" Whether or not to delete ?")){alert(" File deleted ");} 
    return false; 
<a href="#" id="link"> Whether or not to delete </a> 

The above code implements our requirements, and the link will only be used as a normal button. Here, we mainly use the return false statement in the click event of the link, which can cancel the default action of the link

Related articles: