我写了一个 jquery 函数,从那里我尝试用 animate 函数切换不透明度,但我的代码不起作用。谁能告诉我错在哪里。谢谢
jQuery.fn.blindToggle = function (speed, easing, callback) {
var _opacity = 0;
var h = this.height() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));
$(this).toggle(function () {
_opacity = 0;
},
function () {
_opacity = 1;
});
alert(_opacity);
return this.animate({ opacity: _opacity,
marginTop: parseInt(this.css('marginTop')) < 0 ? 0 : -h
}, speed, easing, callback);
};