首页 > 关于在mousedown事件中写animate动画会阻止默认事件发生.

关于在mousedown事件中写animate动画会阻止默认事件发生.

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Demo</title>
    <style type="text/css">
    *{margin:0;padding:0;box-sizing:border-box;}
    html,body{
        height:2000px;
    }
    </style>
</head>
<body>
    <a href="http://www.baidu.com">baidu.com</a>
<script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script type="text/javascript">
    $('a').click(function(){
        console.log(2);
    });
    
    $('a').mousedown(function(){
        console.log(1);
        $('html,body').stop(false, true).animate({scrollTop: '500'}, 500);

    });
</script>
</body>
</html>

不跳转是因为 return false 但是会触发click
不知道你是不是其他地方写错 我测试从jq1.7--2.1都没有出现你说的问题

【热门文章】
【热门文章】