How to use in JavaScript Dom tr deleteCell

In this article I have described about tr deleteCell() method used in JavaScript.
  • 1535

tr deleteCell() method in JavaScript

  • If we want to delete a particular cell within a table then we can use tr deleteCell() method.

Browser support

Following are the main browsers which support the tr deleteCell() method

  • Internet Explorer.
  • Firefox.
  • Opera.
  • Google Chrome.
  • Safari.

Syntax

The syntax of tr deleteCell() method as follows

trObject.deleteCell(index)

Lets take an example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">

    function displayResult()

    {

        var firstRow = document.getElementById("Table").rows[0];

        firstRow.deleteCell(0);

    }

</script>

</head>

<body style ="background-color:green">

<table id="Table" border="1">

  <tr>

    <td>TEA</td>

    <td>COFFEE</td>

    <td>COLDDRINK</td>

  </tr>

</table>

<br />

<button type="button" onclick="displayResult()">DELETE CELLS </button>

</body>

</html>

 

Output

 

CELLFIG1.jpg

When we click on DELETE CELLS button

CELLFIF2.jpg

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.