Looking at my index.html, I see the following code:
<div id="mydiv">
Text inside div
<h1>
Header inside div
</h1>
</div>
<h1>
Header outside div
</h1>
My style.css file is defined like this:
#mydiv h1 {
color: blue;
}
If I want to change the color of "Text inside div" using JavaScript, I can use the following script:
document.getElementById("mydiv").style.color = "red";
However, I am now faced with the challenge of changing the color of "Header inside div" using only JavaScript without making alterations to the HTML or CSS files or affecting the h1 outside the div. How can this be achieved?