Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在单击“无限”时设置此框的动画;按钮“;?_Jquery_Animation - Fatal编程技术网

Jquery 如何在单击“无限”时设置此框的动画;按钮“;?

Jquery 如何在单击“无限”时设置此框的动画;按钮“;?,jquery,animation,Jquery,Animation,如何使此动画在单击按钮后永远运行 $("button").click(function(){ var a=$("#an"); a.animate({width:200,opacity:0.5},"slow"); a.animate({height:200,opacity:0.5},"slow"); a.animate({width:100,opacity:0.8},"slow"); a.animate({height:100,opacity:0.8},"s

如何使此动画在单击按钮后永远运行

$("button").click(function(){
    var a=$("#an");
    a.animate({width:200,opacity:0.5},"slow");
    a.animate({height:200,opacity:0.5},"slow");
    a.animate({width:100,opacity:0.8},"slow");
    a.animate({height:100,opacity:0.8},"slow");
})
试试这个:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

<input type="button" id="button" value="start" />

<div id="an" style="width:100px; height:100px;background-color:red">

<script>
$("#button").click(function(){

    var a = $("#an");
    if ($(this).val() == 'start') {
        $(this).val("stop");
        var v = setInterval(function(){animate(a)},1000);
    }

})

function animate(a) {
    a.animate({width:200,opacity:0.5},"slow");
    a.animate({height:200,opacity:0.5},"slow");
    a.animate({width:100,opacity:0.8},"slow");
    a.animate({height:100,opacity:0.8},"slow");
}

</script>

$(“#按钮”)。单击(函数(){
var a=$(“#an”);
if($(this).val()=='start'){
$(此).val(“停止”);
var v=setInterval(函数(){animate(a)},1000);
}
})
函数动画(a){
a、 设置动画({宽度:200,不透明度:0.5},“慢”);
a、 设置动画({高度:200,不透明度:0.5},“慢”);
a、 设置动画({宽度:100,不透明度:0.8},“慢”);
a、 设置动画({高度:100,不透明度:0.8},“慢”);
}

我认为最好使用CSS的动画来实现这一点。我在这里用-webkit前缀编码-

刚刚用这个jQuery触发:

$("button").click(function(){
     $("#an").removeClass('noAnimate').addClass('animate');
});

多描述一下你的问题,它不清楚<代码>:P嗨!欢迎来到StackOverflow。你的问题不清楚。请花更多的时间解释这个问题。我想在单击按钮时重复动画。由“试试这个
”组成的按钮通常都不是好的答案。一个好的答案试图解释问题和解决方案,以教育读者。在我这方面效果很好,看看这把小提琴。嗯,欢迎,你现在想把我的回答标记为“接受”吗谢谢…干得好!但我还有工作要做…所以只在jquery上才有可能:)