【发布时间】:2011-07-28 06:10:57
【问题描述】:
我在一个页面上有几个 DIV,只有一个是打开的,其他的是关闭的,我希望在单击一个关闭的 DIV 时它会打开,并且之前打开的 DIV 会关闭,如果有的话。一切正常,但问题是:滚动条和动画 DIV 中有很多闪烁。
如何消除这种闪烁?
请建议?
$(function () {
$(".OpenedIdea").find("img").first().click(CollapseFunction);
$(".ClosedIdea").find("img").first().click(ExpandFunction);
});
function CollapseFunction() {
$(this).attr("src", srcE);
$(this).unbind("click");
$(this).click(ExpandFunction);
$(this).parents("div.OpenedIdea").first().removeClass("OpenedIdea").
addClass("ClosedIdea");
var ideaDiv = $(this).parents("div").first().next();
ideaDiv.toggle("blind", 300, function () {
$("html,body").animate({ scrollTop: ideaDiv.offset().top - 100 },
{ duration: 'slow', easing: 'swing' });
});
}
function ExpandFunction() {
$(this).attr("src", srcC);
$(this).unbind("click");
$(this).click(CollapseFunction);
$(".OpenedIdea").find("img").first().click();
$(this).parents("div.ClosedIdea").first().removeClass("ClosedIdea").
addClass("OpenedIdea");
var ideaDiv = $(this).parents("div").first().next();
ideaDiv.toggle("blind", 300, function () {
$("html,body").animate({ scrollTop: ideaDiv.offset().top - 100 },
{ duration: 'slow', easing: 'swing' });
});
【问题讨论】:
标签: jquery jquery-ui jquery-animate