I'm new in JavaScript and I'm tring to find out how I can use the same function to different elements in JavaScript.
I.e. how to set the id value for document.getElementById in the function. I do not know why my code does't work.
JavaScript
function onhover(imgx)
{
var x = imgx;
document.getElementById('x').style.opacity=0.5;
}
HTML
<img id="img1" src="img1.jpg" onmouseout="onhover('img1')">
<img id="img2" src="img2.jpg" onmouseout="onhover('img2')">