I am experimenting with javascript to create a mouseover effect that changes the text color of specific tags in an HTML document. Here is an example:
function adjustColor() {
var anchorTags = document.querySelectorAll("#a1");
anchorTags.forEach(function(tag) {
tag.style.color = "green";
});
}
<div onmouseover="adjustColor()">
<a id="a1">Color</a>
<a id="a1">Names</a>
<a id="a1">Places</a>
</div>
Currently, only the text color of the "Color" tag changes to green upon mouseover and not Names and Places. Is there a way for my function to apply the color change to all anchor tags with similar IDs?