我写了一个jquery函数,从那里我尝试用动画函数切换不透明度,但我的代码不起作用.任何人都可以告诉我哪里是错误.谢谢
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);
};
Run Code Online (Sandbox Code Playgroud)
jQueryanimate有一个你想要做的事情的快捷方式:
$(this).animate({"opacity": "toggle"});
Run Code Online (Sandbox Code Playgroud)
那你就不需要自己实现那个逻辑了.
| 归档时间: |
|
| 查看次数: |
8037 次 |
| 最近记录: |