How to add elements dynamically

I am creating an accordion on a dynamic product page, to show the “Additional Info” sections.

I can get the Additional info through code.

I need to generate the right number of header and fold boxes.
Each product might have a different number of Additional Info sections
So I need to create container boxes and text boxes with code, and add them to the page dynamically.

Is this possible?
If so, how?

Thanks!

Hey,
You can’t add elements to the page dynamically, but you can hide or collapse boxes and then show or expand them dynamically depending on the number of Additional Info sections.

HTH,
Tova

You might be able to use a Repeater if the additional information that you have repeats.

Thanks @yisrael-wix , I looked at that. However it seems you can’t “connect” items to the Additional Info sections, so they have to be populated via code. And with a repeater all the elements have the same name so targeting them with code would be tricky. Unless you can point me to an example of a custom accordion on a dynamic products page showing the additional info sections in a repeater?

Thanks @talyaro that’s what I ended up doing - creating too many accordion sections and only showing the number used.