JQuery UI Accordion 使用问题
我正在尝试使用 JQuery Accordion,但是我在编写代码时遇到了困难。
<div id="accordion">
<h3><a href="#" id="first">First header</a></h3>
<div id="first_content">First content</div>
<h3><a href="#" id="second">Second header</a></h3>
<div id="second_content">Second content</div>
</div>
我想在用户单击标题时更改第一个标题下方的 div 内容,但是我无法理解应该如何编写绑定函数以及手风琴函数中还需要提及的内容
$( "#accordion" ).accordion({
change: function(event, ui) { what to write in here }
});
$( "#accordion" ).bind( "accordionchange", function(event, ui) {
what to write in here
});
假设 HTML 内容是替换为存在于
var html = '<h1>Accordion Usage</h1>';
I am trying to use JQuery Accordion, however I am facing a difficulty in writing the code.
<div id="accordion">
<h3><a href="#" id="first">First header</a></h3>
<div id="first_content">First content</div>
<h3><a href="#" id="second">Second header</a></h3>
<div id="second_content">Second content</div>
</div>
I want to change the content of the div below the first heading when the user clicks the heading, however I am not able to understand that how I should write the binding function and what else to mention in the accordion function
$( "#accordion" ).accordion({
change: function(event, ui) { what to write in here }
});
$( "#accordion" ).bind( "accordionchange", function(event, ui) {
what to write in here
});
Supposing the HTML content to be replaced with is present in
var html = '<h1>Accordion Usage</h1>';
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 文档 中:
因此您可以使用 jQuery 函数来替换元素内容:
或者您可以提供初始化时的回调:
From the documentation:
So you can use the jQuery functions to replace the element content:
or you can supply the callback at initialization: