显示/隐藏ajax? javascript切换 [英] show/hide ajax? javascript toggle

查看:96
本文介绍了显示/隐藏ajax? javascript切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个wordpress插件,该插件会隐藏起来,当我单击说箭头图像时,弹出一个ajax功能,并在其中显示一个联系表单,然后在页面底部显示另一个show hide功能,以显示并隐藏多个div.

I'm looking for a wordpress plugin that hides to start with the when I click say an arrow image an ajax feature pops out with say a contact form inside and also another show hide feature at the bottom of the page to show and hide multiple divs.

有没有可以做所有这些事情的插件?

Is there a plugin that can do all this?

我的客户页面必须是可编辑的,因此我无法将其构建到主题中. javascript函数必须是页面的一部分. 我已经找到WP ShowHide Elements,但这不允许我在同一个位置中对多个div进行处理.

My pages have to be editable for my client so it is impossible for me to build this into the theme. The javascript function needs to be part of a page. I've found WP ShowHide Elements but this does not allow me to do it with multiple divs in the same placement.

这是我的页面插件所允许的一些我正在使用的脚本

Here's some of the script I'm using as allowed by the plugin in my pages

    <p id="mytest">my text</p>
<p><a onclick="wp_showhide('mytest')" href="javascript:void(0);">my link</a></p>
<p id="new">new</p>
<p><a onclick="wp_showhide('new')" href="javascript:void(0);">new</a></p>

感谢您的帮助 问候

朱迪

P.S. http://wordpress.digitalnature.ro/mystique/ 请注意该网站上的侧边栏,这是我要尝试的内容,但仍在主页内容之内

P.S. http://wordpress.digitalnature.ro/mystique/ Please notice the sidebar on this website, this is what I'm trying to achive but within the main page content

此简短脚本可在页面中使用,但我希望使用交换div效果 如何使用它与Multidiv div配合使用? -我想更改所有具有相同空格或div的div的可见性

This short script works within a page but I want a swap div effect How can I use this to work with multipe divs? - i'd like to change the visability of multiple divs all with the same space or div

   <p><script type="text/javascript">
<!--
    function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }
//-->
</script></p>
<p><a onclick="toggle_visibility('foo');" href="#">Click here to toggle visibility of element #foo</a></p>
<div id="foo">This is foo</div>
<p><a onclick="toggle_visibility('too');" href="#">Click here to toggle visibility of element #too</a></p>
<div id="too">This is too</div>

我想我可能已经解决了自己的问题:) 很想知道是否有人可以对其进行修改,以便在页面加载时第一个div已经打开

I think I may have solved my own problem :) Would love to know whether anyone can modify it so the 1st div is already open when the page loads

<p><script type="text/javascript">
lastone='empty'; 
function showIt(lyr) 
{ 
if (lastone!='empty') lastone.style.display='none'; 
lastone=document.getElementById(lyr); 
lastone.style.display='block';
}
</script></p>
<p><a href="JavaScript:;" onClick="showIt('divID')">link</a></p>
<div id="divID" style="display: none;">content</div>
<p><a href="JavaScript:;" onClick="showIt('new')">link</a></p>
<div id="new" style="display: none;">content</div>

推荐答案

要回答您的您不能仅从原始div中删除display:none样式吗?

To answer your edit: can't you just remove the display:none style from the original div?

如果需要用Java脚本执行,请删除showIt('divID');在您的功能后排成一行.

If you need to do it in Javascript, chuck a showIt('divID'); line in after your function.

要正确执行此操作,请将其添加到window.onload:

To do it properly, add it into window.onload:

window.onload = showIt('divID');

或更恰当地说,具有可以加入onload的功能(

Or more properly, have a function that enqueues into the onload (like this).

也许最好,使用框架:)

这篇关于显示/隐藏ajax? javascript切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆