swateen
swateen

Reputation: 1

How to delete specific table rows with javascript?

How can I delete specific table rows by giving up the row number in an input field?

The table I want to target: Complete code is linked below.

<table id="uitvoertabel" border="1">
    <tr>
        <th></th>
        <th>Voornaam</th>
        <th>Achternaam</th>
        <th>Aantal punten</th>
    </tr>
    <tr>
        <td>1</td>
        <td>John</td>
        <td>Cruijff</td>
        <td>54</td>
    </tr>
    <tr>
        <td>2</td>
        <td>Frans</td>
        <td>Bauer</td>
        <td>47</td>
    </tr>
    <tr>
        <td>3</td>
        <td>Selah</td>
        <td>Sue</td>
        <td>93</td>
    </tr>
</table>

This is the complete code: https://jsfiddle.net/c6oLf8ye/1/

Upvotes: 0

Views: 46

Answers (1)

sitaram9292
sitaram9292

Reputation: 171

Pass the row number you want to delete like 0,1,2,3...

document.getElementById("uitvoertabel").deleteRow(0);

updated the same in: https://jsfiddle.net/3v2rdbmt/

Upvotes: 1

Related Questions