2
我想知道是否可以根據某些條件在jQuery的animate
中設置屬性。例如:動畫/任何函數內的條件語句
var condition = offL > ((wW/2) - $this.width());
tooltip.css(function() {
if (condition) {
return '"right", "auto"';
} else {
return '"left", "auto"';
}
}).animate({
"top": $this.offset().top + (posT/2) - (tooltip.height()/2),
if (condition) {
return '"left":"offL - tooltip.width() - 30"';
} else {
return '"right", "offR - tooltip.width() - 30"';
}
}, 300).fadeTo(200, 1);
(tooltip
等瓦爾較早定義。)
這不起作用,很明顯。但是,如果他需要在函數內部使用條件參數,會怎麼樣呢?
另一方面的問題是,我的使用情況爲var
正確嗎?
你不這樣做,你打造出一個變量來保存你所需要的數據。 – Ohgodwhy