there is other way to get properties of cell in JS then event.target.nodeName.toLowerCase()? [closed]
so I have this problem that I want to compare 2 cells of Chess table that I did. When I click on cell, I'm getting in console.log only td, and the comparison I'm using I have the cell itself (I added photo for example) so there is other way to get the cell properties when click on it then the event.target.nodeName.toLowerCase()?
here in this function im sending cell and try to compare it to event.target.nodeName.toLowerCase() the problem is, that in event.target.nodeName.toLowerCase() i have "td" and not the "cell" like shonw in the right side of the photo, so i want to know if there is other opetion whel im clicking on some cell of grid(chess table) that i can get the cell itself to be compared.
const handler= Click.bind(null, cell);
table.addEventListener("click", handler);
function Click(cell, event) {
if (event.target.nodeName.toLowerCase() === 'td' )
{
event.target.style.backgroundColor = "blue";
if (event.target.nodeName.toLowerCase() == cell])
{
alert("SOMETEXT")
}
}
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment