inser a row

 <!DOCTYPE html>

<html>

<head>
    <meta charset=utf-8 />
    <title>Insert row in a table - w3resource</title>
</head>

<body>
    <table id="sampleTable" border="1">
        <tr>
            <td>Row1 cell1</td>
            <td>Row1 cell2</td>
        </tr>
        <tr>
            <td>Row2 cell1</td>
            <td>Row2 cell2</td>
        </tr>
    </table><br>
    <input type="button" onclick="insert_Row()" value="Insert row">





    <script>
        function insert_Row(){
            let table = document.getElementById('sampleTable');
            table.insertAdjacentHTML('beforeEnd', `<tr><td>Row3 Cell1</td><td>Row cell2</td></tr>`)

            
        }
    </script>
</body>

</html>

Comments

Popular posts from this blog

Write a JavaScript program to get the current date.

Store and display the values of text boxes of a form

Write a JavaScript program to count and display the items of a dropdown list, in an alert window