Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add multiple rows to table using JavaScript or jQuery [closed]

How can I add multiple rows to a table dynamically using jQuery or JavaScript.

like image 258
ѕтƒ Avatar asked Jan 14 '23 12:01

ѕтƒ


1 Answers

You can use append() to add single row one after the other :

<table id="add"></table>               
<script type="text/javascript">
    function addRow()
    {
        var str ="";
        for(var i=0;i<20;i++)
        {
            str+="<tr>";
            str+="<td>"+i+"</td>";
            str+="</tr>";
        }
        $('#add').html(str); or $('#add').append(str);
    }
</script>
like image 77
THE ONLY ONE Avatar answered May 21 '23 00:05

THE ONLY ONE