Link to home
Start Free TrialLog in
Avatar of JJ2357
JJ2357Flag for United States of America

asked on

Append to each element by class name

We are looking for a vanilla js solution that will append a common html block after each instance of a dd class name = "alpha".

Example of current state:
<div class="image><dl><dd class="alpha">text string 1</dd></dl></div>
<div class="image><dl><dd class="alpha">text string 2</dd></dl></div>
...
<div class="image><dl><dd class="alpha">text string n</dd></dl></div>

Open in new window

Example of desired state:
<div class="image><dl><dd class="alpha">text string 1</dd><dd class="beta">New html string </dd></dl></div>
<div class="image><dl><dd class="alpha">text string 2</dd><dd class="beta">New html string</dd></dl></div>
...
<div class="image><dl><dd class="alpha">text string n</dd><dd class="beta">New html string </dd></dl></div>

Open in new window


We've been trying insertBefore to no avail.  Many thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial