I am struggling with a basic JavaScript script to select a child element using getElementsByClassName, but it does not seem to be working as expected:
var parent = document.getElementsByClassName('parent');
var child = parent.getElementsByClassName('child');
child.style.color='red';
I have attempted various approaches and researched extensively, only finding answers that involve looping. However, I prefer to achieve this without using loops. Is there a method to accomplish this task?