Jquery SlideUp 闪烁问题
向上滑动后,内容出现奇怪的闪烁。 我已将:添加
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
到代码的头部,但随后整个页面都在跳转并发生下滑,
我的解决方案是什么?
这是我的代码以防万一:
$("#contentbottom").slideUp(500, function() {
var dataString = 'type='+t;
$.ajax({
type: "POST",
url: link,
data: dataString,
success: function(msg)
{
$("#contentbottom").empty().append(msg);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('error: unable to load the additonal info');
},
complete: function()
{
$("#contentbottom").slideDown(500);
}
});
});
I have the strange flash of the content after finishing sliding up.
i have add the:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
to the head of my code but then the entire page is jumping the the slidedown occur
what is my solution?
here is my code just in case:
$("#contentbottom").slideUp(500, function() {
var dataString = 'type='+t;
$.ajax({
type: "POST",
url: link,
data: dataString,
success: function(msg)
{
$("#contentbottom").empty().append(msg);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
alert('error: unable to load the additonal info');
},
complete: function()
{
$("#contentbottom").slideDown(500);
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的猜测是,在没有看到您的任何标记的情况下,
$("#contentbottom").empty().append(msg);
填充了 AJAX 响应,导致您的浏览器闪烁/向下滚动到新内容,然后返回到顶部。如果您没有任何 CSS 样式来隐藏
#contentbottom
元素(当它为空时),则可能是部件问题。你可以在 AJAX 调用之前在幻灯片处理程序中执行$('#contentbottom').hide()
,然后$("#contentbottom").empty().append(msg ).show()
在成功处理程序中...My guess, without seeing any of your markup, is that
$("#contentbottom").empty().append(msg);
is populated with the AJAX response causing your browser to flash/scroll down to the new content, then back up to the top.If you don't have any CSS styles to hide the
#contentbottom
element when it's empty, that might be a part problem. Yu could just do$('#contentbottom').hide()
in your slideUp handler before you AJAX call, then$("#contentbottom").empty().append(msg).show()
in the success handler...