HTML code to replace some Javascript for an accordion
Geovista
Registered Users Posts: 2 Beginner grinner
Hi
Can anyone please help with HTML code to replace some Javascript for an accordion? I know very little about HTML or anything like this.
I closely followed this https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_symbol to build an accordion FAQs page on my site (unpublished). It looks good, however the accordion panels won't open when clicked. I'm told by one of the Smugmug Heroes that it is because there is Javascript in the HTML code, which Smugmug doesn't allow. They advised I seek help here. So I please need HTML code to replace the following Javascript:
<script>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>
Also, does anyone know how to indent only some paragraphs in a panel in the accordion?
Many thanks
Grant
Can anyone please help with HTML code to replace some Javascript for an accordion? I know very little about HTML or anything like this.
I closely followed this https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_symbol to build an accordion FAQs page on my site (unpublished). It looks good, however the accordion panels won't open when clicked. I'm told by one of the Smugmug Heroes that it is because there is Javascript in the HTML code, which Smugmug doesn't allow. They advised I seek help here. So I please need HTML code to replace the following Javascript:
<script>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>
Also, does anyone know how to indent only some paragraphs in a panel in the accordion?
Many thanks
Grant
Tagged:
0
Comments
You can check out this: https://gallery.imagesinthebackcountry.com/Smugmug-customization/Create-a-Responsive-Accordion-Menu-for-SmugMug
Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
You can add a special class for your indent paragraphs. In this case I added
.indent
to one of the second paragraph.HTML
CSS
If you don't want to indent the first line, you can remove
text-indent: 20px;
.Images in the Backcountry
My SmugMug Customizations | Adding CSS to Your Site | SEO for the Photographer | Locate Your Page/Widget Number | SmugMug Help Desk
The link and your tip were very helpful. I also found this link useful: https://supfort.com/css-accordion-animation.