【问题标题】:jquery grabbing current div or wildcard placeholder for show/hide functionjquery 抓取当前 div 或通配符占位符以显示/隐藏功能
【发布时间】:2009-10-15 07:46:14
【问题描述】:

我有下面的代码

<div id=topbar>
<a class="nav" href="#" onClick="if($('#embedding').css('display') == 'none') { $('#embedding').show('fast'); } else { $('#embedding').hide('fast'); } return false;">Show Details</a>
<div id=embedding>Content</div>
</div>

在显示嵌入层的链接中,有什么方法可以代替#embedding,我可以做一些事情,让它抓住下一个div,这样我就可以动态使用它了吗?

想用它在 PHP 中格式化一些 MySQL 结果。

更新 对于那些想知道的人,这就是解决方案

<a class="nav" href="#" onClick="if($(this).next('div').css('display') == 'none') { $(this).next('div').show('fast'); } else { $(this).next('div').hide('fast'); } return false;">Show Details</a>

【问题讨论】:

    标签: php jquery


    【解决方案1】:

    使用jquery对象的next()方法:

    <a href="#" onclick="$(this).next('div').toggle();">Toggle next div</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-24
      • 1970-01-01
      • 2016-09-14
      • 2012-05-16
      • 2013-03-20
      • 1970-01-01
      • 2013-06-05
      • 2018-02-16
      相关资源
      最近更新 更多