Help me to understand. Created 3 pictures by js. Task : when I hover over the image, the description appears in another DIV. But only the first picture works, the rest are not. How to check which image is the mouse hovering? Tried and through document Id, and Name to address, but, probably, somehow not so.
// Воин var imgW = document.createElement ('img'); imgW.src = 'img/warrior.png'; imgW.id = 'imgWarrior'; imgW.name = 'imgWarrior'; //img.setAttribute('onClick', 'imgClick();'); imgW.setAttribute('onMouseOver', 'imgOver();'); imgW.setAttribute('onMouseOut', 'imgOut();'); document.getElementById('q').appendChild(imgW); // Охотник var imgH = document.createElement ('img'); imgH.src = 'img/hunter.png'; imgH.id = 'imgHunter'; imgH.name = 'imgHunter'; //img.setAttribute('onClick', 'imgClick();'); imgH.setAttribute('onMouseOver', 'imgOver();'); imgH.setAttribute('onMouseOut', 'imgOut();'); document.getElementById('q').appendChild(imgH); // Маг var imgM = document.createElement ('img'); imgM.src = 'img/mage.png'; imgM.id = 'imgMage'; imgM.name = 'imgMage'; //img.setAttribute('onClick', 'imgClick();'); imgM.setAttribute('onMouseOver', 'imgOver();'); imgM.setAttribute('onMouseOut', 'imgOut();'); document.getElementById('q').appendChild(imgM); function imgOver () { if (imgW) { document.getElementById('w').innerHTML = '<p><strong>Блядский Воин</strong>.</p>'; }else if (imgH){ document.getElementById('w').innerHTML = '<p><strong>Охотник за шелупонью</strong>.</p>'; }else{ document.getElementById('w').innerHTML = '<p><strong>Маг подщельник</strong>.</p>'; }; } function imgOut () { document.getElementById('w').innerHTML = ''; }