【发布时间】:2011-07-19 17:57:19
【问题描述】:
我只需要在 else if 块内设置不同的 animate() 的 marginLeft 值,而在 else if 块中的所有其他值都应该相同。脚本如下:
var timeoutID = window.setTimeout(
function(){
if (imgs.index(imgElement) == 0) {
imgElement.animate({
width: "315px",
height: "225px",
marginTop: "-50px",
marginLeft: "-150px",
}, 1500 );
imgElement.css("z-index","100");
imgElement.css("position","absolute");
imgElement.css("opacity","1");
}
else if (imgs.index(imgElement) == 1) {
//The same thing but marginLeft: "-200px"
}
}, 1500);
【问题讨论】:
-
在 6 分钟内发布 6 个可行的答案 - 你被宠坏了!
-
不相关:您可以用单个
css({'property1': 'value1', 'property2': 'value2'})调用替换对css('property', 'value')的多个调用。 -
@Radu - 它是相关的 - 主题是关于 jQuery 优化。我什至将它包含在我的答案中。 :)
标签: javascript jquery coding-style