JSFiddle - React, Tailwind, and code Playground

HTML

<div id="div1">
  <span></span>
</div>

<div id="div2">
    
</div>

CSS

div {
    width: 100px;
    height: 100px;
    border: 1px solid black;
}

.red {
    background-color: red;
}

JavaScript

// Both lines of code should do:
//  - select div
//  - insert "bar" after any children
//  - go back to div
//  - add "red" class to div

$("#div1").children().after("bar").end().addClass("red");
$("#div2").children().after("bar").end().addClass("red");