我正在尝试使用 Jquery.UI 库,问题是,jqueryui.com 上给出的示例是当您传递效果类型时,我想在其中加载淡出
JSFiddle 在这里
我的代码
<div id="effect">
<h3>Hide</h3>
<p>Etiam libero neque, luctus a, eleifend nec, semper at, lorem. Sed pede. Nulla lorem metus, adipiscing ut, luctus sed, hendrerit vitae, mi.</p>
</div>
<script>
$( document ).ready(function() {
$( "#effect" ).hide( "blind", 1000, callback );
});
</script>
最佳答案
因为 callback
没有定义。这就是为什么您会收到错误并且代码无法运行的原因。
您可以简单地删除它或定义回调
函数:
$( document ).ready(function() {
$( "#effect" ).hide( "blind", 1000);
});
或
$( document ).ready(function() {
var callback = function () { console.log("foo"); }
$( "#effect" ).hide( "blind", 1000, callback);
});
要了解什么是回调
,请阅读更多 here .
使用 hide()
jQuery 方法,您可以将函数作为最后一个参数传递。查看documentation .
complete
Type:
Function()
A function to call once the animation is complete.
关于jquery - 为什么我的div不淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22132116/