I'm trying to test some JS on a page i'm making. I'm new to it so i'm trying something simple. Apparently it's too challenging for me. Here is my code for the div:
<div class="ni">
<div class="ni_image" onclick="changeColor()">
<div class="text_box">
<h3>Northern Ireland</h3>
</div>
</div>
<div class="ni_info">
<p>info</p>
</div>
</div>
Here is the CSS for the outer div if you need it:
.ni {
width: 600px;
height: 220px;
display: block;
margin: 0px 0px 60px 0px;
}
And the style I'm trying to change in .ni_image:
background-color: lightblue;
The only other style attributes for this div are width/height, display, and margins/padding. If they're helpful please comment and I'll add them.
Finally here is the JS I'm testing:
function changeColor() {
document.getElementsByClassName('.ni_image').style.backgroundColor = "red";
}
I've looked at StackOverflow and loads of other forums, and from what I've read I have no idea where I'm going wrong. I've linked the local .js file with a script tag in the head tag.
Any help would be greatly appreciated.