javascript - annimate只能执行一次
PHP中文网
PHP中文网 2017-04-10 17:43:10
[JavaScript讨论组]

写了个p代码,发现只能执行一次,搜网页,发现可以多次执行,到底要怎么才能多次执行,按钮状态可以多次,但是p不行

<script>
$(document).ready(function(e) {
    
        var w=Math.floor(Math.random()*document.documentElement.clientWidth);
    var h=Math.floor(Math.random()*document.documentElement.clientHeight);
    $("p").offset();
    
    $("#btn").mouseenter(function(e){
            $("p").animate({
            "width":"100px",
            "top":h,
            "left":w
            },2000);

        });    
            
});
</script>
<body>
<p style="position:relative;background-color:red ;width:50px;height:50px" ><input type="button" style="float:left "   value="你点不到我"   id="btn"   /></p>
</body>
PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(1)
伊谢尔伦

$("#btn").mouseenter(function(e){
var w=Math.floor(Math.random()*document.documentElement.clientWidth);

var h=Math.floor(Math.random()*document.documentElement.clientHeight);
        $("p").animate({
        "width":"100px",
        "top":h,
        "left":w
        },2000);

    });    
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号