jQuery:如何在页面加载时将顶部滑动面板保持在CLOSED状态(jQuery : How to keep a Top Sliding Panel in CLOSED state on page load)
嗨,我正在编写一个小的jQuery脚本,它将在网站上切换隐藏的顶部面板。
我的脚本是这样的:
// Expand Panel $("#open").click(function(){ $("div#top-panel").slideDown("slow"); }); // Collapse Panel $("#close").click(function(){ $("div#top-panel").slideUp("slow"); }); // Switch buttons from "Open" to "Close" on click $("#toppaneltoggle a").click(function () { $("#toppaneltoggle a").toggle(); });HTML就是这样的:
<div id="top-panel" class="one"> <div class="wrap"> <div class="widget"> <jdoc:include type="modules" name="top-panel" style="xhtml" /> </div> </div> </div> <div class="tab"> <li id="toppaneltoggle"> <a id="open" class="open" href="#">Checkout Special Offers</a> <a id="close" style="display: none;" class="close" href="#">Close This Panel</a> </li> </div>目前在页面加载时,面板状态为OPEN,但切换在单击其关闭的选项卡时工作正常。 我的问题是我希望此面板在页面加载时处于CLOSE状态,并且只有在单击选项卡时才会打开。
我如何实现这一目标?
请帮助。
Hi I am writing a small jQuery script which will toggle a hidden Top-Panel on the site.
My Script is like this:
// Expand Panel $("#open").click(function(){ $("div#top-panel").slideDown("slow"); }); // Collapse Panel $("#close").click(function(){ $("div#top-panel").slideUp("slow"); }); // Switch buttons from "Open" to "Close" on click $("#toppaneltoggle a").click(function () { $("#toppaneltoggle a").toggle(); });and the HTML is like this:
<div id="top-panel" class="one"> <div class="wrap"> <div class="widget"> <jdoc:include type="modules" name="top-panel" style="xhtml" /> </div> </div> </div> <div class="tab"> <li id="toppaneltoggle"> <a id="open" class="open" href="#">Checkout Special Offers</a> <a id="close" style="display: none;" class="close" href="#">Close This Panel</a> </li> </div>Currently on page load the panel state is OPEN however the toggle works fine on clicking the tab it closes. My issue is that I want this panel to be in a CLOSE state on page load and it should open only when clicked on the tab.
How do I achieve that?
Kindly help.
最满意答案
岂不
<div id="top-panel" class="one" style="display: none;">工作?
Wouldn't
<div id="top-panel" class="one" style="display: none;">work?
更多推荐
发布评论