JSFiddle - React, Tailwind, and code Playground
HTML
<div placeid="987">
<button onclick="createNewElm()">
</button>
</div>
<input type="text" class="idholder" value="123">
JavaScript
var type = "whatever";
function addElm(type) {
var elm = '<div class="subelm" data-type="' + type +"></div>";
return elm;
}
createNewElm(
'/usercontrols/AjaxCall/AddElement.ashx',
{
Id: $(this).parent().attr('placeid'),
Call: 'content',
Type: type,
elm: addElm(type),
Page: $('.idholder').val()
}
);
function createNewElm(sUrl, sData) {
$.post(sUrl, sData);
}