Get TableRow Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableRow

Introduction

The TableRow object represents an HTML <tr> element.

You can access a <tr> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
}
</style>//from ww  w.  j  a  va 2  s.co  m
</head>
<body>

<table>
  <tr id="myRow">
    <td>First cell</td>
    <td>Second cell</td>
    <td>Third cell</td>
  </tr>
</table>

<button onclick="myFunction()">delete the first cell from the table row</button>

<script>
function myFunction() {
    var row = document.getElementById("myRow");
    row.deleteCell(0);
}
</script>

</body>
</html>

Related Tutorials