Javascript Jquery fadein和fadeout脚本不工作
如果框未设置动画且显示值为无,则单击class=“display”时,该功能应在id=“Box”中淡出;如果#框的显示值为非无,则该功能应淡出。怎么了Javascript Jquery fadein和fadeout脚本不工作,javascript,jquery,Javascript,Jquery,如果框未设置动画且显示值为无,则单击class=“display”时,该功能应在id=“Box”中淡出;如果#框的显示值为非无,则该功能应淡出。怎么了 $(document).ready(function() { $('.display').click(function() { var currentDisplayValue = $('#Box').css('display'); if (':animated') { stop()
$(document).ready(function() {
$('.display').click(function() {
var currentDisplayValue = $('#Box').css('display');
if (':animated') {
stop()
};
else if (currentDisplayValue == 'none') {
$('#Box').fadeIn("slow");
};
else {
$('#Box').fadeOut("slow");
};
});
谢谢试试:
$(function() {
$(".display").click(function() {
var box = $("#Box");
if (box.is(":animated")) {
box.stop();
} else if (box.is(":hidden") {
box.fadeIn("slow");
} else {
box.fadeOut("slow");
}
});
});
您有一些语法错误(例如大括号后面的分号),需要将stop()
应用于jquery集。最后,不要像现在这样检查当前的显示CSS值。改用:hidden
选择器