javascsript:向 Dreamweaver 中的 spry 可折叠面板添加加号/减号图标
我正在修改一个网站,该网站有一个常见问题解答图表,其中有一个问题链接。
如果单击问题链接,则会在下拉菜单中显示答案。
我的目标是用链接文本旁边的减号图标替换加号图标图像,以实现下拉显示操作。
常见问题解答使用 Spry Collapsible Panel (sprycollapsiblepanel.js) 来管理链接的显示/隐藏。在我开始修改 javascript 源代码中的代码之前,我想知道是否有人可能知道有一种更简单的方法可以通过 Dreamweaver 来完成此操作。
提前致谢。
更新: 调用 show/reveal 操作的 html 是:
<div class="CollapsiblePanel">
<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="1">Fax to E-Mail</div>
<div class="CollapsiblePanelContent">Here is the text content as it relates to Fax to E-Mail</div>
</div>
</div>
构造下拉菜单的操作,Spry 需要在页面底部添加以下内容:
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
var CollapsiblePanel3 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel3", {contentIsOpen:false});
</script>
I'm working on modifying a website which has a chart of FAQs which have has a question link.
If question link is clicked, it reveals the answer in a drop down.
My goal is to swap out a plus icon image with a minus icon next to the linked text for the drop down reveal action.
the FAQs use Spry Collapsible Panel (sprycollapsiblepanel.js) to manage the show/hiding from the link. before I go about modifying the code in the javascript source code, I was wondering if there was an easier way of doing this through dreamweaver someone might be aware of.
thanks in advance.
UPDATE:
the html calling the show/reveal actions are:
<div class="CollapsiblePanel">
<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="1">Fax to E-Mail</div>
<div class="CollapsiblePanelContent">Here is the text content as it relates to Fax to E-Mail</div>
</div>
</div>
The construct the actions for the drop down, Spry requires the following at the bottom of the page:
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
var CollapsiblePanel3 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel3", {contentIsOpen:false});
</script>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 SpryCollapsiblePanel.css 中,修改以下样式规则:
这会增加左侧的填充,以为图像腾出空间。
然后将图像添加到以下规则中:
In SpryCollapsiblePanel.css, amend the following style rules:
This increases the padding on the left to make room for the image.
Then add the images to the following rules:
插件在打开和关闭时为每个面板标题添加一个类,分别是“
CollapsiblePanelOpen
”和“CollapsiblePanelClosed
”。这样你就可以使用CSS来添加+-效果和背景图像。THe plug ins adds a class to each panel title when is opened and when is closed, these are "
CollapsiblePanelOpen
" and "CollapsiblePanelClosed
" accordingly. With that you can use CSS to add the +- effect with a background image perhaps.onclick 切换图像,然后 onclick 其他内容切换回 + 号
onclick switch an image then onclick of something else switch back to + sign
如果它是图像,并且您不想更改源代码,并且想要使用 JavaScript,则需要更改图像的
src
属性。您可以将此代码放在您需要的任何位置(在
onclick
或函数或其他位置)。此外,图像的 URL 显然需要更新。If it's an image, and you don't want to change the source code, and you want to use javascript, you'll need to change the
src
property of the image.You can put this code in wherever you need (in an
onclick
or a function or whatever). Also, the URLs for the images will obviously need to be updated.使用一些简单的 JavaScript 即可轻松修复。
添加以下脚本:
完成后查看定义可折叠面板的 div。它看起来像这样:
要使其工作,您所需要做的就是添加 onclick="name();"到语法:
Easy fix with some simple JavaScript.
Add the following script:
When that's done look at the div defining the collapsible panel. It looks something like this:
All you need for this to work is to add onclick="name();" to the syntax: