【问题标题】:Expand/collapse not working using java script in html在 html 中使用 javascript 展开/折叠不起作用
【发布时间】:2015-07-27 06:56:17
【问题描述】:

这是链接http://jsfiddle.net/susxK/124/ 当我点击客户服务没有发生任何事情时,任何人都可以帮助我解决这个问题。

预期输出:

clicking the  customer services i want to show the full table.In the same way collapse. 

【问题讨论】:

    标签: javascript html collapse expand


    【解决方案1】:

    这将显示和隐藏您的表格

    $(document).ready(function() {
        $(".form-matrix-table").hide();
    
        $(".form-label,form-label-top").click(function() {
             $(".form-matrix-table").toggle();
        });
    });
    

    【讨论】:

    • 如果我有多个具有不同类的表意味着使用单个函数如何编写假设 $(".form-matrix-table1").hide(); $(".form-label,form-label-top1").click(function() { $(".form-matrix-table1").toggle(); });
    • 对不起,你想说什么?
    • 假设我有多个不同的类名,如何为所有编写 hide() 并单击 function()
    • 看到刚才我被编辑了你的帖子这样对吗?
    【解决方案2】:

    只需在您的 html 代码中添加 onclick="name()" 侦听器:

    Working Demo : Fiddle

    onclick="d()"

    HTML

    <label class="form-label form-label-top" onclick="d()" id="label_5" for="input_5"> Customer Services </label>
    

    CSS

    #cid_5{
        display:none;
    }
    

    JS

    function d()
    {
             $("#cid_5").fadeToggle();
    }
    

    【讨论】:

      猜你喜欢
      • 2014-11-03
      • 2012-12-04
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 2015-02-15
      • 2013-01-20
      • 2011-11-08
      • 1970-01-01
      相关资源
      最近更新 更多