爲什麼oldHeight
的值沒有被覆蓋?它仍然有oldHeight
到80
不是我通過的參數。即使我通過參數newHeight
,它也不會覆蓋它。但根據documentation,它會自動更新。下面的代碼:jQuery自定義函數
(function($) {
$.fn.bad = function(callback) {
var options;
var settings = $.extend({
"oldHeight":"80",
"newHeight":"200"
}, options);
return this.each(function() {
var that$ = $(this);
that$.bind("mouseenter", function() {
$(this).animate({ "height" : settings.newHeight+"px" });
}).bind("mouseleave", function() {
$(this).animate({ "height" : settings.oldHeight+"px" });
});
});
}
})(jQuery);
$(".box").bad({"oldHeight":"400"});
這===>Fiddle
這是壓倒一切的,不是嗎?盒子在小提琴上越來越大 – 2013-02-27 10:43:17
嘿,我已經在mouseleave的時候分配了'400',但它被限制爲默認選項。 – 2013-02-27 10:44:18
哎呀,我的壞...誤解了這個問題! – 2013-02-27 10:44:57