JSFiddle - React, Tailwind, and code Playground
by Qwerty_Wasd
CSS
body > .child {
color: red;
}
JavaScript
window.addEventListener(`load`, () => {
let [
parent,
child,
count
] = [
`<div class="parent"></div>`,
`<div class="child">ТЫК</div>`,
10
];
;[parent, child].forEach(el => document.body.insertAdjacentHTML(`beforeend`, el));
while (count--)
document.getElementsByClassName(`parent`)[0].insertAdjacentHTML(
`beforeend`,
document.getElementsByClassName(`child`)[0].outerHTML
);
document.addEventListener(`click`, e => {
if (e.target.classList.contains(`child`))
alert(`!!!!!`);
});
});