为什么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