gpt4 book ai didi

jquery - #accordion 不是一个函数

转载 作者:行者123 更新时间:2023-11-30 23:50:02 26 4
gpt4 key购买 nike

Accordion 脚本出现问题,当我使用直接 html 时, Accordion 可以工作,但现在转移到 wordpress, Accordion 已停止工作。

这是我的代码

  <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(); ?>

和 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 中工作。我什至尝试用纯文本删除包含功能,但它仍然不起作用?

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

最佳答案

您将加载 jQuery 两次(先加载 1.5,后加载 1.7.1),并在加载 1.5 之后、加载 1.7.1 之前加载 jQuery UI。所以会发生以下情况:

  1. jQuery 1.5 已加载。

  2. jQuery UI 已加载,并将其自身附加到此时存在的 jQuery 对象。

  3. 加载 jQuery 1.7.1,完全取代 jQuery 对象。

  4. 您的代码使用 (1.7.1) jQuery 对象运行,jQuery UI 尚未向该对象添加其优点。

如果您只加载 jQuery 一次,并确保随后加载 jQuery UI,它就会起作用。

关于jquery - #accordion 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9017634/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com