關于執(zhí)行后彈窗問題。連續(xù)彈出窗口三次,怎么阻止冒泡,只彈出一次。
?<select?id="animation"> ????????<option?value="1">動畫step動畫</option> ????????<option?value="2">動畫progress回調</option> ????</select> ????<a></a> ????<input?id="exec"?type="button"?value="執(zhí)行動畫"> ????<script?type="text/javascript"> ????????$("#exec").click(function(){ ????????var?v?=?$("#animation").val(); ????????var?a?=?$("#aaron"); ????????if(v?==?"1"){ ????????????a.animate( ????????????{?height:'50'}, ????????????{duration:2000, ?????????????step:function(now,fx){ ????????????????a.text('高度的改變值:'+now) ?????????????}? ????????????}) ????????} ????????else?if(v?==?"2"){ ?????????????a.animate(? ????????????{height:'70'}, ????????????{duration:2000, ?????????????progress:function(now,fx){ ???????????????a.text('進度'+arguments[1]), ???????????????alert('執(zhí)行結束'); ?????????????} ????????????})???? ????????} ????}) ????</script>
連續(xù)彈出窗口三次,沒彈出一次 進度增加一次。怎么能只彈出一次。然后進度直接從0-1。
2017-07-22
這不是冒泡,也不只彈出三次。你把alert改成console.log看看就知道了。
如果要只彈出一次,那就把alert寫在complete里:
至于進度直接從0變成1,這個我不知道,大概要用.stop()方法吧。