jQuery hide()div直到完全加载
我正在为我的博客使用标签式精选post。 如何实现div#latest-featured
会在内容完全加载后hide()
然后show()
回来吗?
$(document).ready(function() { //Default Action $(".tab_content").hide(); //Hide all content $("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() { $("ul.tabs li").removeClass("active"); //Remove any "active" class $(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content $(activeTab).fadeIn(); //Fade in the active content return false; }); });
HTML
Content for title 1
Why I want to hide the #latest-featured because.. when had image @ script here.. the tab_content will collapse all and break my design
Content for title 1
Why I want to hide the #latest-featured because.. when had image @ script here.. the tab_content will collapse all and break my design
示例我有一个id为#latest-featured
的div,我希望隐藏它直到内容完全加载,然后在加载所有内容后再显示它。
如何实现上面的当前代码。
可能最好做这样的事情:
$(function() { // do work $("div#latest-featured").show(); }
默认情况下隐藏任何东西通常都不是一个好主意,但这符合您的要求。
如果你希望它显示一旦加载声明CSS display: none
为该div,然后调用$('div#latest-featured').show();
在你的$(document).ready函数中。
为什么不将div设置为display:none,直到你加载了数据,然后删除display:none …有很多方法可以做我刚刚提到的btw(例如,jQuery .toggle(true))
如果你希望它显示一旦加载声明CSS显示:none为该div,然后调用$('div#latest-featured').show();
在你的$(document).ready
函数中。
罗伯特回答得最好,我会投票,但还不能……几个小时寻找这个解决方案,这是我发现的最好的……