youroleksii Posted August 7, 2023 Posted August 7, 2023 Hi all, trying to hide the accordion block and make it appear after clicking on a button. Here is the code that I use, Could anyone look and say where is the pain point here? <SCRIPT> function ShowAndHide() { var x = document.getElementById('section[data-section-id="64d15395c579ed75d02954dc"]'); if (x.style.display == 'none') { x.style.display = 'block'; } else { x.style.display = 'none'; } } </SCRIPT> <BUTTON ONCLICK="ShowAndHide()">Strategy</BUTTON> <DIV ID="section[data-section-id="64d15395c579ed75d02954dc"]" STYLE="display:none">Text to be shown and hidden</DIV> Thank you!
creedon Posted August 7, 2023 Posted August 7, 2023 Are you married to the button as your method of toggling? I have some code that uses sections to hide/show other sections. Check the demo. If you still want a button, let us know and we may be able to help. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment