取消后续事件

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>New Web Project</title>
        <script type="text/javascript" src="js/jQuery1.11.1.js"></script>
        <script type="text/javascript" >
            
            $(function(){
                $("#myhref").click(function(event){
                    //能力检测
                event=event||window.event;
                if(event.preventDefault){  //非IE下内核 webkit引擎
                    event.preventDefault();
                }else{
                    event.returnValue=false; //IE引擎
                }
                
                });
            });
                
            
        </script>
        
    </head>
    <body>
        <a id="myhref" href="http://www.cnblogs.com">去百度</a>
    </body>
</html>

此时点击去百度之后,不会发生页面跳转

原文地址:https://www.cnblogs.com/alexanderthegreat/p/7105027.html