JSFiddle - React, Tailwind, and code Playground
by venkateshwar
HTML
<div id="parentDiv">
<div>child1</div>
<div>child2</div> <span> span </span>
</div>
CSS
#parentDiv>div {
width: 100px;
height: 100px;
background-color:green;
}
JavaScript
var pDiv = document.getElementById('parentDiv');
var cDiv = pDiv.children;
for (var i = 0; i < cDiv.length; i++) {
if (cDiv[i].tagName == "DIV") {
cDiv[i].style.color = 'red';
}
}