Click table row and get value of all cells

后端 未结 5 945
温柔的废话
温柔的废话 2020-12-31 16:05

I don\'t know JQuery, so I\'m hoping there is a way to do this in pure Javascript.

I need to click on a table row and get the value of each cell in that row. Here i

5条回答
  •  悲哀的现实
    2020-12-31 17:01

    var elements  = document.getElementsByTagName('td');
    for (var i =0; i < elements.length; i++) {
       var cell_id = 'id' + i;
       elements[i].setAttribute('id', cell_id);
    }
    

    Maybe put something like this in function your onclick links to from the tr?

提交回复
热议问题