Jquery accordion activate from external links
I am having a lot o开发者_StackOverflowf trouble trying to open certain J query UI accordion sections from external links. I am calling form functions from hyperlinks.
Links are opening sections but then they click back to original position. any help would be much appreciated. Here the source.
<script>
$(function() {
$( "#accordion" ).accordion({
autoHeight: false,
});
});
</script>
<script>
function Clicked1(){
$("#accordion").accordion('activate' , 0)
}
function Clicked2(){
$("#accordion").accordion('activate' , 1)
}
</script>
<div class="demo">
<a href="" onclick="Clicked1()">OPEN1</a>
<a href="" onclick="Clicked2()">OPEN2</a>
<div id="accordion">
<h3>< href="#section1" >Section 1</a></h3>
<div>
<p>Mauris mauris ante, blandit et, ultrices a, susceros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.</p>
</div>
</div>
</div><!-- End demo -->
Based on the API of accordion, you should use:
$( "#accordion" ).accordion({ active: 2 });
http://docs.jquery.com/UI/Accordion
I made your example work by putting an actual tag into the href you did the onclick
for, as:
<a href="#section1" onclick="clicked2()">;
Write accordion code
collapsible: true
精彩评论