jQuery:如何在页面加载时将顶部滑动面板保持在CLOSED状态(jQuery : How to keep a Top Sliding Panel in CLOSED state on page l

编程入门 行业动态 更新时间:2024-10-26 16:27:56
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?

更多推荐

本文发布于:2023-07-28 23:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1310120.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时将   面板   加载   状态   页面

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!