I want to make a battleship game and I have a problem with mouseover
event in Javascript. I want to make a function that will change element's text content to "X" when is mouse over this element.
Javascript:
var gridShips = document.querySelectorAll('.ships');
for(var i=0; i++; i<gridShips.length){
gridShips[i].addEventListener('mouseover', function(e){placeShips(e)}, false);
}
function placeShips(e){
e.target.textContent = 'X';
}
But when I get my mouse over this element nothing changes. Only when I click on this element, the text content is changing to 'X'. I don't know where is the problem.