如何在已完成的菜单中自定义闭合手风琴默认的脚本

时间:2017-11-03 17:39:40

标签: javascript jquery html css css3

我使用以下内容为Mobiles创建了一个手风琴菜单,效果很好。我想应用一个jquery来默认关闭所有部分。

在标题中:

<link href='https://fonts.googleapis.com/css?family=Jaldi:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/reset.css">
<!-- CSS reset -->
<link rel="stylesheet" href="css/style.css">
<!-- Resource style -->
<script src="js/modernizr.js"></script>

我准备好的代码是:

<ul class="cd-accordion-menu animated">
<li class="has-children">
<input type="checkbox" name ="group-1" id="group-1" checked>
<label for="group-1"><strong>
<font-color: "white">
&nbsp;&nbsp;MENU: CLICK OPEN, CLICK CLOSE</strong></font></label>
<ul>
<li><a href="../index.shtml" target="_self">Home</a></li>
<li class="has-children">
<input type="checkbox" name ="sub-group-1" id="sub-group-1">
<label for="sub-group-1">+ About us</label>
<ul>
<li><a href="../virtualcenter.html" target="_self">Virtual Center Studies</a></li>
<li><a href="../contact.html" target="_self">Contact Us</a></li>
<li class="has-children">
<input type="checkbox" name ="sub-group-2" id="sub-group-2">
<label for="sub-group-2">+ Correspondence and Links</label>
<ul>
<li><a href="../testimonial.html" target="_self">Am I </a></li>
<li><a href="../letters.html" target="_self">Letters to Editor</a></li>
<li><a href="../Online-Resources.html" target="_self">Related Links</a></li>
<li><a href="../open-letters.html" target="_self">Open Letters</a></li>
</ul>
</ul>
</li>
<li class="has-children">
<input type="checkbox" name ="sub-group-3" id="sub-group-3">
<label for="sub-group-3">+ History</label>
<ul>
<li><a href="../modknow.html" target="_self">Archaeology</a></li>
[snip] -- more of the same
Ending with:
<script src="js/jquery-2.1.4.js"></script> 
<script src="js/main.js"></script>

我想使用的Jquery是:

<script>
jQuery(function($){
    $('.et_pb_accordion .et_pb_toggle_open').addClass('et_pb_toggle_close').removeClass('et_pb_toggle_open');

    $('.et_pb_accordion .et_pb_toggle').click(function() {
      $this = $(this);
      setTimeout(function(){
         $this.closest('.et_pb_accordion').removeClass('et_pb_accordion_toggling');
      },700);
    });
});
</script>

我不知道如何自定义上面的JQuery以使其适用于我的代码。

感谢。

1 个答案:

答案 0 :(得分:0)

无需更多答案。我找到了答案并且非常简单:更改:&#39;输入类型=&#34;复选框&#34; name =&#34; group-1&#34; ID =&#34;组-1&#34;检查&#39;至: &#39;输入类型=&#34;复选框&#34;数据肘节=&#34;崩&#34; name =&#34; group-1&#34; ID =&#34;组-1&#34;&#39;