admin管理员组文章数量:1389866
So I have tried everything and cannot seem to figure this out, what I have is an accordian that plugs in data dynamicly, what I need to happen is I need the id of the data to be pluged in as the id for the h3 section that then is in turn clicked and opened...
<script>
jQuery(function() {
jQuery( "#work" ).accordion({
collapsible: true,
active: 1});
});
</script>
So right now the first H3 will be open, but I want to be able to set which div by the H3 id
<h3 id='$record[wid]'>
<a id='clickable' href='#'>
<div class='workitem'>
<span class='mosaic-overlay'>
<div class='details'>
<a name='$record[wid]'></a>
<span class='title'>$record[title]
</span>
<br />
<span class='subtitle'>$record[subtitle]
</span>
</div>
</span>
<span class='mosaic-backdrop'>
<img src='/img/work/$record[image]' />
</span>
</div>
</a>
</h3>
So I have tried everything and cannot seem to figure this out, what I have is an accordian that plugs in data dynamicly, what I need to happen is I need the id of the data to be pluged in as the id for the h3 section that then is in turn clicked and opened...
<script>
jQuery(function() {
jQuery( "#work" ).accordion({
collapsible: true,
active: 1});
});
</script>
So right now the first H3 will be open, but I want to be able to set which div by the H3 id
<h3 id='$record[wid]'>
<a id='clickable' href='#'>
<div class='workitem'>
<span class='mosaic-overlay'>
<div class='details'>
<a name='$record[wid]'></a>
<span class='title'>$record[title]
</span>
<br />
<span class='subtitle'>$record[subtitle]
</span>
</div>
</span>
<span class='mosaic-backdrop'>
<img src='/img/work/$record[image]' />
</span>
</div>
</a>
</h3>
Share
Improve this question
edited Oct 31, 2012 at 18:48
Renato Gama
16.6k12 gold badges60 silver badges98 bronze badges
asked Oct 31, 2012 at 18:42
Chris James ChampeauChris James Champeau
9943 gold badges16 silver badges37 bronze badges
1
-
How will you determine which
<h3>
id to take (assuming<h3>
are the accordion folds)? This isn't hard, but we don't have quite enough information. – Michael Berkowski Commented Oct 31, 2012 at 18:51
2 Answers
Reset to default 3On the accordion I use in my project, I just set the active to "h3#" + the id of the accordion fold I want to open.
<script type='text/javascript'>
jQuery(function() {
jQuery( "#work" ).accordion({
collapsible: true,
active: "h3#id"
});
});
</script>
I believe its the standard jQueryUI accordion, so hopefully it will work for you too.
For anyone else who came across this older topic, jQuery Accordion now uses a number based value for the "active" option > https://api.jqueryui./accordion/#option-active > 0 = the first accordion tab > 1 = the second accordion tab etc. active: 1 will display the second accordion tab open/active. Additionally you probably want to use the autoHeight, clearStyle and heightStyle options so that you do not have additional whitespace at the bottom of the active accordion tab.
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function($){
$( "#accordion" ).accordion({
collapsible: true,
active: 1,
autoHeight: true,
clearStyle: true,
heightStyle: "content"
});
});
/* ]]> */
</script>
本文标签: javascriptJquery accordionSet Active by IDStack Overflow
版权声明:本文标题:javascript - Jquery Accordion, Set Active by ID - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669067a2618713.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论