Jquery #手风琴不是一种功能

Jquery #手风琴不是一种功能,jquery,wordpress,function,Jquery,Wordpress,Function,手风琴脚本有问题,当我使用纯html时,手风琴工作,但现在移动到wordpress后,手风琴已停止工作 这是我的密码 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js">&l

手风琴脚本有问题,当我使用纯html时,手风琴工作,但现在移动到wordpress后,手风琴已停止工作

这是我的密码

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
  <script>
  $(document).ready(function() {
    $("#accordion").accordion();
  });
  </script>
<?php wp_head(); ?>

$(文档).ready(函数(){
$(“#手风琴”)。手风琴();
});
以及html:

            <div id="accordion">
 <div class="button"><a href="#">Infrastructure</a></div>
    <div><?php
            if (function_exists('iinclude_page')){
                iinclude_page('sectors/infrastructure');
            }?>
            </div>
    <div class="button"><a href="#">Housing</a></div>
    <div><?php
            if (function_exists('iinclude_page')){
                iinclude_page('sectors/housing');
            }?></div>
                <div class="button"><a href="#">Education</a></div>
    <div><?php
            if (function_exists('iinclude_page')){
                iinclude_page('sectors/education');
            }?></div>
                <div class="button"><a href="#">Health</a></div>
    <div><?php
            if (function_exists('iinclude_page')){
                iinclude_page('sectors/health');
            }?></div>
</div>

我真的不理解这个问题,因为它在纯html中工作。我甚至尝试过用纯文本删除include函数,但它仍然不起作用


有什么想法吗?也没有其他jquery对象相互干扰。

您将jquery包含了两次,也许这就是问题所在

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
..
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

..

您将加载jQuery两次(1.5之后是1.7.1),并在加载1.5之后但在加载1.7.1之前加载jQuery UI。下面是发生的情况:

  • jquery1.5已加载

  • jQuery UI被加载并将自身附加到该点上存在的
    jQuery
    对象

  • jQuery 1.7.1被加载,完全替换了
    jQuery
    对象

  • 您的代码使用(1.7.1)
    jQuery
    对象运行,jqueryui并没有添加它的优点


  • 如果只加载一次jQuery,并确保随后加载jqueryui,它就会工作。

    在Wordpress上运行jQuery时,能否显示完整的html。 我在想,可能在包含页面中有一些未关闭的标签会损坏手风琴

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
    
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    
    
    

    并且尽量不要插入jQuery两次。

    源代码中的html与在浏览器中查看源代码时看到的html有什么区别吗?进行优化的插件将尝试挤出不必要的换行符。if general总是在空标记(脚本或其他)中放置html注释。类似于我的意思;)谢谢你对原因的解释。谢谢,这太奇怪了,因为我从jquery网站本身复制并粘贴了代码到手风琴页面上,其中包括代码中的两个版本@艾米:很高兴这有帮助!我看不到jqueryui.com上加载了两个版本的jQuery。他说得有道理,因为没有php标记,它运行得很好:@gideon我做了同样的检查:-),但我想看看带有Wordpress includesah的html。是的,我想知道为什么有人-1,因为这是非常有效的,所以我+1:)