第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

感覺這樣寫有點(diǎn)煩,有更簡潔的辦法沒?比如用判斷語句?

<!DOCTYPE html>
<html>
??? <head>
??????? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
??????? <title>jQuery動畫特效</title>
??????? <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
??????? <style >
??????????? div{
??????????????? position:absolute;
??????????????? top:200px;
??????????????? width:50px;
??????????????? height:50px;
??????????????? background-color:red;
??????????????? color:white;
??????????????? border-radius:20px;
??????????????? text-align:center;
??????????????? line-height:20px;
??????????????? left:50px;
??????????????? }
??????? </style>
??
??? <body>
??????? <input id="left" type="button" value="左移" />
??????? <input id="right" type="button" value="右移" />
??????? <div><font></font></div>
??????? <script>
??????????? $(function(){
??????????? var $timel=0;
??????????? var $timer=0;
??????????? $("#left").bind("click",function(){???????????????? ++$timel;
??????????????? $("div").animate({
??????????????????? left:"+=50px"
??????????????? },3000,function(){
??????????????????? $(this).animate({
??????????????????????? width:'+=20px',
??????????????????????? height:'+=20px'
??????????????????? },2000,function(){
??????????????????????? $("font").html("第"+$timel+"次左移");
??????????????????? });
??????????????? });
???????????? });
??????????????? $("#right").bind("click",function(){
??????????????????? ++$timer;
??????????????????? $("div").animate({
??????????????????????? left:"-=50px"
??????????????????? },3000,function(){
??????????????????????? $(this).animate({
??????????????????????????? width:'-=20px',
??????????????????????????? height:'-=20px'
??????????????????????? },2000,function(){
??????????????????????????? $("font").html("第"+$timer+"次右移");
??????????????????????? });
??????????????????? });
??????????????? });
??????????? });
??????? </script>
??? </body>
</html>

正在回答

3 回答

我用了一個function來包裹變形的動作 代碼如下

<script>
????????????$(function(){
????????????????var?$timel?=?0;
????????????????var?$timer?=?0;
????????????????var?$symbol?=?"";
????????????????var?$chart?=?"";
????????????????$("#left").bind("click",?function(){
????????????????????$symbol?=?"-";
????????????????????$chart?=?"左";
????????????????????$timel++;
????????????????????$time?=?$timel;
????????????????????Move($symbol,?$chart,?$timel);
????????????????});
????????????????$("#right").bind("click",?function(){
????????????????????$symbol?=?"+";
????????????????????$chart?=?"右";
????????????????????$timer++;
????????????????????Move($symbol,?$chart,?$timer);

????????????????});

????????????????function?Move($symbol,?$chart,?$time){
????????????????????$("div").animate({
????????????????????????left:$symbol?+?"=50px"
????????????????????},3000,function(){
????????????????????????
????????????????????????$(this).animate({
????????????????????????????width:?$symbol?+?'=20px',
????????????????????????????height:?$symbol?+?'=20px'
????????????????????????????},2000,function(){
????????????????????????????????$("font").html("第"?+?$time?+?"次"?+?$chart?+?"移");
????????????????????????????});
????????????????????});
????????????????}
????????????})
</script>


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

玥_ 提問者

厲害
2016-05-05 回復(fù) 有任何疑惑可以回復(fù)我~
#2

肥仔匯 回復(fù) 玥_ 提問者

我也是初學(xué)者 大家一同 學(xué)習(xí)一同進(jìn)步
2016-05-05 回復(fù) 有任何疑惑可以回復(fù)我~

?<script>

? ? ? ? ? ? $(function(){

? ? ? ? ? ? var $timel=0;

? ? ? ? ? ? var $timer=0;

? ? ? ? ? ? $("#left").bind("click",function(){ ? ? ? ? ? ? ??

? ? ? ? ? ? ? ? go($timel,"-=50","-=20")

? ? ? ? ? ? ?});

? ? ? ? ? ? ? ? $("#right").bind("click",function(){

? ? ? ? ? ? ? ? ? ? go($timer,"+=50","+=20")

? ? ? ? ? ? ? ? });

? ? ? ? ? ? });

? ? ? ? ? ? function go(time,dis,wh){

? ? ? ? ? ? ? ? ++time;

? ? ? ? ? ? ? ? $("div").animate({

? ? ? ? ? ? ? ? ? ? left:dis+"px"

? ? ? ? ? ? ? ? },3000,function(){

? ? ? ? ? ? ? ? ? ? $(this).animate({

? ? ? ? ? ? ? ? ? ? ? ? width:wh+"px",

? ? ? ? ? ? ? ? ? ? ? ? height:wh+"px"

? ? ? ? ? ? ? ? ? ? },2000,function(){

? ? ? ? ? ? ? ? ? ? ? ? $("font").html("第"+time+"次右移");

? ? ? ? ? ? ? ? ? ? });

? ? ? ? ? ? ? ? });

? ? ? ? ? ? }

? ? ? ? </script>


1 回復(fù) 有任何疑惑可以回復(fù)我~

可以把兩個bind合并到一起啊。?$("#right").bind().bind();這樣會稍微簡單點(diǎn)吧

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
jQuery基礎(chǔ)課程
  • 參與學(xué)習(xí)       154724    人
  • 解答問題       7289    個

加入課程學(xué)習(xí),有效提高前端開發(fā)速度

進(jìn)入課程

感覺這樣寫有點(diǎn)煩,有更簡潔的辦法沒?比如用判斷語句?

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號