Bootstrap手风琴jQuery脚本在Apache服务器上不起作用

时间:2017-10-09 12:47:26

标签: jquery apache bootstrap-4

  

的jQuery

$('.accordions').each(function(){

        // Set First Accordion As Active
        $(this).find('.accordion-content').hide();
        if(!$(this).hasClass('toggles')){
            $(this).find('.accordion:first-child').addClass('accordion-active');
            $(this).find('.accordion:first-child .accordion-content').show();
        }

        // Set Accordion Events
        $(this).find('.accordion-header').click(function(){

            if(!$(this).parent().hasClass('accordion-active')){

                // Close other accordions
                if(!$(this).parent().parent().hasClass('toggles')){
                    $(this).parent().parent().find('.accordion-active').removeClass('accordion-active').find('.accordion-content').slideUp(300);
                }

                // Open Accordion
                $(this).parent().addClass('accordion-active');
                $(this).parent().find('.accordion-content').slideDown(300);

            }else{

                // Close Accordion
                $(this).parent().removeClass('accordion-active');
                $(this).parent().find('.accordion-content').slideUp(300);

            }

        });

    });
  

HTML

<ul class="accordions">
                        <!-- Accordion -->
                        <li class="accordion">
                            <div class="accordion-header">
                                <div class="accordion-icon"></div>
                                <h6>Section 1</h6>
                            </div>
                            <div class="accordion-content" style="display: none;">
                                <p>text</p>
                            </div>
                        </li>
                        <!-- /Accordion -->

您好, 以下jQuery代码在本地修改时工作正常。当我尝试在本地Apache服务器上运行它时,click事件不会注册。我正在使用jQuery 1.11(不在CDN上运行它)。我做错了什么?

0 个答案:

没有答案