I'm trying to create an onclick function that returns the row and the column of the clicked cell from a table in JavaScript without using jQuery. What I have so far will return the column, but I can't figure out how to make it return the row.
  **cellToAppend.addEventListener("click", clicked);**
  **function clicked() {
    alert("clicked cell at: " + (this).cellIndex + ", ");
  }**
                Use parentNode to get the row.
function clicked() {
    alert("clicked cell at: " + this.cellIndex + ", " + this.parentNode.rowIndex);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With