1
根據一個變量(nextItem
)是否大於另一個(currentItemRel
),我有一個函數可以將div(container
)設置爲向左或向右。將變量傳遞給.animate()函數JQuery
我遇到的問題是在.animate()
函數中使用distance
變量。
如何傳遞此變量?目前我的JavaScript正在打破,所以任何幫助,將不勝感激。
三江源
var distance = (nextItem - currentItemRel) * 1260;
if (nextItem > currentItemRel)
{
$('#container').animate({ left: -=distance }, 1200);
} else if (nextItem < currentItemRel)
{
$('#container').animate({ left: +=distance }, 1200);
};
我只是想在箱子外面,把它作爲一個變量。謝謝,小提琴很棒! –