What i need is a different el.style.height depends on amount of child nodes.. So for example in a second div with class links -> a tags should have style="height: 100px"; I have build this:
function sameHeightLinks() {
var linkContainers = document.querySelectorAll('.links');
for (var i = 0; i < linkContainers.length; i++) {
var linkContainer = linkContainers[i];
var linkItself = linkContainer.children[0];
var linksAmount = linkContainer.childElementCount;
if (linksAmount == 2) {
linkItself.style.height = '59.5px';
}
}
}
sameHeightLinks();
<div class="links">
<a>Some link</a>
<a>Some link</a>
<a>Some link</a>
<a>Some link</a>
</div>
<div class="links">
<a>Some link</a>
<a>Some link</a>
</div>
<div class="links">
<a>Some link</a>
<a>Some link</a>
<a>Some link</a>
</div>
As you may see it works because im targeting only first child node here. But as soon as im trying add additional for cycle in order to go through all a tags -> it does not work.. What would be the right syntax in this specific case? Im sure that there should be 2 for cycles. But i think that i just cant get "ALL children" right..
PS: IE 11 support is required