First of all, I use Plate CMS(runs on shopify liquid), this is creating the sections
you can see in the image above.
Now im struggeling with a small problem. I want to loop all 6 sections but only 4 of them are placed inside a div and the other 2(the header and footer) are so called tray's
, meaning there are a bit diffrent and won’t be placed inside that div.
I know i can loop through the 4 sections usingsomethign like this:
$('#mydiv > section').each(function () { /* ... */ });
but the problem is that i can’t select the header and footer this way.
and then i loop on the div above it will loop the <div data-id="post_15757">
and not the sections inside.
How do i use a loop like this: $('#mydiv > section').each(function () { /* ... */ });
, but also add my header and footer?
2
Answers
You can use jQuery add
or in order:
or perhaps just
You can also select on data attribute:
This makes it almost certain, sections created by the CMS will be selected, and not HTML sections from integration.