added row to a table with jquery but added rows disappear with browser refresh

Posted by user840930 on Stack Overflow See other posts from Stack Overflow or by user840930
Published on 2012-07-03T15:07:22Z Indexed on 2012/07/03 15:15 UTC
Read the original article Hit count: 268

Filed under:
|
|
|

I added rows to a html table with jquery, but when I refresh the browser, the rows disappear. How can I get the rows to stay?

<TABLE id="dataTable" width="100%" align="center">
    <TR align="center" border="1">
        <TH></TH>
        <TH>ID </TH>
        <TH>Name</TH>
        <TH>Status</TH>
    </TR>
    <TR align="center">
        <TD><INPUT type="checkbox" name="chk"/></TD>
        <TD> 1 </TD>
        <TD> <INPUT type="text" value="Submission 1" /> </TD>
        <TD>Working version</TD>
    </TR>
</TABLE>

<script type="text/javascript">

$(document).ready(function(){
$('#createNew').click(function() {
    var table = document.getElementById('dataTable');

    var rowCount = table.rows.length;

    $('#dataTable tr:last').after('<TR align="center"><TD><INPUT type="checkbox" name="chk"/></TD><TD>'+ rowCount + '</TD><TD> <INPUT type="text" value="Submission 1" />   </TD><TD>Working version</TD></TR>');

© Stack Overflow or respective owner

Related posts about html

Related posts about table