I am having trouble getting my JavaScript code to change the CSS style of my article element. I have this in the opening tag for my article element:
”’
<img id="n1" onmouseover="visible('c1')" src="img/musicnote1.png" alt="Music Note">
”’
and then at the bottom of my body section I have my script tag:
”’
<script>
function visible(a){
document.getElementById(a).style.display = initial;
document.getElementById('default').style.display = none;
}
</script>
”’
I am trying to make the ‘c1’ article appear and the ‘default’ article disappear when the user hovers over the image. Neither of these actions are working
2
Answers
It seems you need to assign strings as attributes: