Javascript get the text value of a column from a particular row of an html table

前端 未结 2 1121
说谎
说谎 2020-12-14 10:02

A user clicks on a row of a table, and I want to get (in Javascript) the innerhtml of let\'s say the 3rd column of that row.

Something like :

documen         


        
2条回答
  •  粉色の甜心
    2020-12-14 10:11

    in case if your table has tbody

    let tbl = document.getElementById("tbl").getElementsByTagName('tbody')[0];
    console.log(tbl.rows[0].cells[0].innerHTML)
    

提交回复
热议问题