Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
123
rated 0 times [  129] [ 6]  / answers: 1 / hits: 15798  / 11 Years ago, thu, october 31, 2013, 12:00:00

I'm using jQuery accordion plugin.



When clicked on the text Accordion, it expands and show the content, as it should. Now, I also have a Close button at the bottom of accordion to close it and that also works as it should.



Now the requirement is, when I click on Accordion, it should expand and hide that text Accordion and it should show again when closed using Close.



How to achieve that? So far I have:



<script>
$(function() {
$( #accordion ).accordion({
collapsible: true,
active: false
});
});
</script>


and



<div id=accordion>
<h3>Accordion</h3>
<div class=accordionBg>
<p>...text here...</p>
<p>...text here...</p>

<div id=accordion>
<h4>Close</h4>
</div>

</div>
</div>



  1. How can I use onclick() function to hide and show the header of this accordion?



    Also, I'm sure using duplicate id gives html validation error,


  2. How should I stay safe from duplicating id?



More From » jquery

 Answers
6

Just add this CSS



.ui-state-active { display:none }



This will hide the Accordian text and show it when you click close.


[#74584] Wednesday, October 30, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
milo

Total Points: 62
Total Questions: 99
Total Answers: 97

Location: Sweden
Member since Mon, May 8, 2023
1 Year ago
;