2010-07-18 80 views
0

我不知道什麼是錯的這個代碼..它只是不,即使它與另外一個相同的語法工作..jQuery的動畫

$(document).ready(function(){ 
$("#inner").animate({height:'200',top:'-100'},1000); 
    $("#inner").animate({width:'200',margin-left:'-100'},1000); 
}); 

你可以看到的例子here。 。

+0

您好..請幫助.. :(IM出來是怎麼回事,我的代碼的想法.. :( – 2010-07-18 07:15:24

+0

@vrynxzent看我的編輯... – 2010-07-18 07:19:27

回答

0

嘗試不PX給$("#inner").animate({width:'200',margin-left:'-250'},1000);

還是看這個question上SO

它說,

嘗試使用「marginTop」而不是「margin-top」。通常,當您使用CSS道具作爲「border-something」或「margin-something」時,最好使用它的「標準化」版本,就像您在DHTML(styles.marginTop)中使用的那樣。

所以將其更改爲, $("#inner").animate({width:'200',marginLeft:'-250'},1000);

或者

你也可以使用redsquare的答案...

+0

仍然不會工作.. – 2010-07-18 07:05:08

+0

@vrynxzent嘗試我編輯的部分... – 2010-07-18 07:20:27

+0

wahhhhhhhhhh ..它的作品..非常感謝先生.. :) – 2010-07-18 07:23:23

1

您需要引用保證金左屬性,因爲連字符是一個保留JS操作。

update到您的演示

嘗試

$(document).ready(function(){ 
$("#inner").animate({height:'200',top:'-100'},1000); 
    $("#inner").animate({width:'200','margin-left':'-100'},1000); 
});