JSFiddle - React, Tailwind, and code Playground

HTML

<body>
<div title="Title 1">DIV 1</div>
<div title="Title 2">DIV 2</div>
<div title="Title 3">DIV 3</div>
</body>

CSS

div.foo {
    color: red;
}

JavaScript

var settings = {
    headingClass: "foo"
};

$("div").each(function (i) {
    var $this = $(this);
    var $div  = $("<div>").addClass(settings.headingClass).attr("title", $this.attr("title")).text("New DIV " + (i+1));
    
    $div.insertBefore($this).click(function () {
        alert($this.attr("title"));
    });
});