2013-10-12 42 views
0

嘿我試圖重寫這段代碼的代碼,但它只能部分代碼是假設在其移動內容DIV同時移動框。內容div .c_right只會移動,但.icon-menu-2不會移動。我怎樣才能解決這個問題?下面是代碼:試圖重寫JavaScript的

var timer; 

$(".icon-menu-2").animate({marginRight: "30px", queue: false, duration: "slow", display: "toggle"}); 
$(".c_right").animate({marginRight: "215px", queue: false, duration: "slow", display: "toggle"} 
, function() { 
    timer = setTimeout(function() { 
$(".icon-menu-2").animate({marginRight: "-155px", queue: false, duration: "slow", display: "toggle"});  
$(".c_right").animate({marginRight: "215px", display: "toggle"}, {queue: false, duration: "slow"}) 
    }, 500); 
}); 

http://jsfiddle.net/5b5zH/3/

如何解決我的代碼?

回答

0
var timer; 

$(".icon-menu-2").animate({marginRight: "30px", queue: false, duration: "slow", display: "toggle"}); 
$(".c_right").animate({marginRight: "215px", queue: false, duration: "slow", display: "toggle"} 
, function() { 
    timer = setTimeout(function() { 
    $(".c_right").animate({marginRight: "215px", display: "toggle", 'padding-right':$(".c_left").width()}, {queue: false, duration: "slow"}, 500); 

$(".icon-menu-2").animate({marginRight: "-155px", queue: false, duration: "slow", display: "toggle"}); 
     $(".c_left").animate({marginRight: "215px", display: "toggle"}, {queue: false, duration: "slow"}) 
    }, 500); 

}); 

這是否適合您?不確定你想要什麼

http://jsfiddle.net/7mFGx/