I'm looking to create a wrapper that acts as the immediate parent of any HTML markup added within a shared class. This will eliminate the need to manually add multiple wrapper divs and allow for the customization of layouts and backgrounds.
Essentially, I want any element with the class .page to automatically generate a wrapper around its content. Here's an example of what I'm aiming for:
<div class="page">
<div class="wrapper"> <!-- AUTO-GENERATED WRAPPER -->
<!-- Content goes here -->
</div><!-- AUTO-GENERATED WRAPPER -->
</div>
I've considered using PHP for this task, but after searching, I came across a JavaScript solution which seemed closest to what I need: See Michal's answer. If anyone has ideas on how to implement this with a loop in pure JS, I would greatly appreciate it. Thank you!