这是我的代码,我正在使用jquery的本地文件。我一直在尝试向该代码中添加一个手风琴,但是它没有响应。我试图发出警报,以查看我的JavaScript是否正常工作,并且看到它正在响应,我不知道我的代码有什么问题。
<div id="accordion">
<h3><a href="#">Web development journey</a></h3>
<div>
<p>This how i ended up into the programming field...</p>
</div>
<h3><a href="#">Early Childhood and Education</a></h3>
<div>
<p>I waas born somewhere in the year 1999. I was born in a small village called Masuka village in Gokwe town, Midlands province, Zimbabwe.I am the first and lastborn...</p>
</div>
<h3><a href="#">Secondary and Tertiary education</a></h3>
<div>
<p>In my grade 7, I managed to score enough marks.....
</p>
</div>
</div>
<script>
$(document).on('ready', function() {
$("#accordion").accordion();
});
</script>
使用jQuery UI示例:https://jqueryui.com/accordion/我从您的代码创建了以下内容。
$(function() {
$("#accordion").accordion();
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div id="accordion">
<h3><a href="#">Web development journey</a></h3>
<div>
<p>This how i ended up into the programming field...</p>
</div>
<h3><a href="#">Early Childhood and Education</a></h3>
<div>
<p>I waas born somewhere in the year 1999. I was born in a small village called Masuka village in Gokwe town, Midlands province, Zimbabwe.I am the first and lastborn...</p>
</div>
<h3><a href="#">Secondary and Tertiary education</a></h3>
<div>
<p>In my grade 7, I managed to score enough marks.....
</p>
</div>
</div>
这正在按预期方式工作。请检查您的代码以获取正确的语法。