JSFiddle - React, Tailwind, and code Playground
HTML
<div id="con"></div>
JavaScript
function createElement(el, prop, target) {
var props = prop.split('.'),
newelement = $(el),
id = '',
className = '';
$.each(props, function(i, val) {
if(val.indexOf('#') >= 0) {
id += val.replace(/^#/, '');
} else {
className += val + ' ';
}
});
if(id.length) newelement.attr('id', id);
if(className.length) newelement.attr('class', className.trim());
$(newelement).html('Newly born').appendTo(target);
$("<div></div>").append("<p></p>").appendTo($('#test'))
}
createElement('div', '#test.a.b', '#con');