简体   繁体   中英

Dynamics table creator Or <td> <tr> creator

If i have a table with 5 rows and 4 column.but i have to add values on the next row.there is no database related dependency.I have ADD button and i want to code it like when ever i will click on ADD button there is aaddition of new row....... I mean the creaton of Rows in the table willbe dynamically...

Can ayy one sho me any sample code /Link on http://jsfiddle.net/ or just give me any Url that contains the demo code for that

See this tutorial . It show how to add new row and column.


I don't know how to do on jsFiddle but made one demo on my machine and is as follows:

<html>
<head>
<title>Demo</title>
<script>
    function appendRow(tblId)
    {
        var tbl = document.getElementById(tblId);
        var newRow = tbl.insertRow(tbl.rows.length);
        var newCell = newRow.insertCell(0);
        newCell.innerHTML = 'Hello World!';
    }
</script>
</head>
<body>
<table id="tabl" border="1">
    <tr>
        <td>Old one</td>
    </tr>
</table>
<input type="button" value="AddRow" onClick="appendRow('tabl')">
</body>

完整的JQuery在表中添加行可能会有所帮助

Here you go: http://jsfiddle.net/dgMET/1/

var table = document.getElementById("table");
var row = table.insertRow(table.rows.length);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM