[英]What am I doing wrong in this jQuery link?
在jQuery方面,我是一个完全新手,但我正在尝试在我的HTML页面上运行一个简单的accordion()代码。
这是我用过的链接,我包含了压缩生产jQuery 2.1.0
<head>
<link rel="stylesheet" type="text/css" href="stylesheetkomik2.css">
<script src="jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="scriptkomik2.js"></script>
<title>Komiktoneel</title>
</head>
我正在尝试使用accordion()的代码片段是一系列带有标签的标签,其中包含段落,如下所示:
<div id="content">
<h3>This is the first heading</h3>
<div><p>First paragraph</p></div>
<h3>This is the second heading</h3>
<div><p>Second paragraph</p></div>
</div>
scriptkomik2.js除了以下代码之外什么都不包含:
$(document).ready(function(){
$("#content").accordion();
})
我的代码中有什么问题或链接错误吗? 谢谢
您需要添加jQuery UI
Accordion
是一个来自jQuery UI的小部件,这个库在jQuery之上运行。 因此,您需要将两个j添加到项目中。
<script src="js/jquery.js"></script>
<script src="js/jquery.ui.js"></script>
缺少jQueryUI 。 你必须为手风琴小部件添加jQueryUI。
<head>
<link rel="stylesheet" type="text/css" href="stylesheetkomik2.css">
<script src="jquery-2.1.0.min.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="scriptkomik2.js"></script>
<title>Komiktoneel</title>
</head>
.accordion不是一个有效的jQuery方法。 我想你正在寻找jquery UI: https : //jqueryui.com/accordion/
尝试实现它,看看会发生什么。
添加以下脚本标记。 Accordion是jQuery UI的一部分
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.