I've checked a number of sites trying to figure this out. However, I have had no luck and figured I would go ahead and make a post on here.
What I am trying to do is setting the Active Accordion depending on ID. Below, is what I am working with.
jQuery Code:
$(function () {
$("#accordion").accordion({
collapsible: true,
header: "h3",
active: 'h3.content3',
heightStyle: "content"
});
});
HTML:
<div id="accordion">
<h3 class="content1">Content Title</h3>
<div align="left">
<p>Content for 1 Goes Here</p>
</div>
<h3 class="content2">Content Title</h3>
<div align="left">
<p>Content for 2 Goes Here</p>
</div>
<h3 class="content3">Content Title</h3>
<div align="left">
<p>Content for 3 Goes Here</p>
</div>
</div>
I hope I explained it well enough, If not, Let me know. I'll try to help ya.
I've checked a number of sites trying to figure this out. However, I have had no luck and figured I would go ahead and make a post on here.
What I am trying to do is setting the Active Accordion depending on ID. Below, is what I am working with.
jQuery Code:
$(function () {
$("#accordion").accordion({
collapsible: true,
header: "h3",
active: 'h3.content3',
heightStyle: "content"
});
});
HTML:
<div id="accordion">
<h3 class="content1">Content Title</h3>
<div align="left">
<p>Content for 1 Goes Here</p>
</div>
<h3 class="content2">Content Title</h3>
<div align="left">
<p>Content for 2 Goes Here</p>
</div>
<h3 class="content3">Content Title</h3>
<div align="left">
<p>Content for 3 Goes Here</p>
</div>
</div>
I hope I explained it well enough, If not, Let me know. I'll try to help ya.
Share Improve this question edited Mar 4, 2014 at 15:20 Spokey 11k2 gold badges31 silver badges44 bronze badges asked Mar 4, 2014 at 15:03 ZGold92ZGold92 231 silver badge3 bronze badges 3- I don't get it... what do you want to set active? – Spokey Commented Mar 4, 2014 at 15:07
- Looks like you need to set a number, not a string: $( ".selector" ).accordion({ active: 2 }); – ravb79 Commented Mar 4, 2014 at 15:08
- but it works.. jsfiddle/Spokey/uKzpp what version are you using? – Spokey Commented Mar 4, 2014 at 15:13
1 Answer
Reset to default 5Set active
based on the h3
index:
active: $('#accordion h3').index($('.content3'))
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745433124a4627484.html
评论列表(0条)