dcAccordian问题在wordpress中展开崩溃

时间:2014-07-25 09:41:44

标签: jquery html wordpress wordpress-plugin

您好我在我的插件菜单中使用dcAccordion jquery文件。我为崩溃添加了一个属性并将其扩展为文件并为其创建条件并使用加号(+)减号( - )来表示它。

当我第一次打开网站时,标志显示在父菜单上,现在,如果我点击父菜单,加号转换为减号,但是当我点击子菜单时,减号再次转为加号。不知道发生了什么。

这是我的代码:

在dcAccordion文件中折叠/展开属性

expandCollaps: true

这是我的条件

// Here is my condition
if (defaults.expandCollaps == true) {
    $('li.' + classParentLi, obj).each(function() {
    var state = {
    collapse: '<span class="wpc-collapse"> (-)<span>',
    expand: '<span class="wpc-expand"> (+)</span>'
}
$(this).find('a').first().append(state.expand);
$(this).click(function() {
if ($(this).find('span').hasClass('wpc-collapse')) {
    $(this).find('span').remove();
    $(this).find('a').first().append(state.expand);
 } else {
     $(this).find('span').remove();
     $(this).find('a').first().append(state.collapse);
  }
});


});
 }

1 个答案:

答案 0 :(得分:0)

好的,我在插件主页中添加了这段代码

<?php
function wpc_accordiaon() {
    ?>
    <script type="text/javascript">
        jQuery(document).ready(function() {
            jQuery('.wpc-categories li a.active').find('.wpc-expand').toggleClass('wpc-collapse');
        })
    </script>
<?php
}
?>

我的dcAccordion工作完美