Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot read property 'childNodes' of null while appending to a table

I guess it will be a quite obvious answer I'll get but I really can't find it myself.

Here's my table (I spare you all the tds)

<table id="COA_Table">
    <thead>
        <tr>some th</tr>
    </thead>
    <tbody>
        <tr>some TD</tr>
    </tbody>
</table>

and here is my jQuery code:

$(document).ready(function () {
    console.log("ready!");

    $('#COA_Table > tbody:last').append('<tr><td><input type=\"checkbox\"></td><td></td>New account<td></td><td></td></tr>');
})

and to finish with, the error code I get:

Uncaught TypeError: Cannot read property 'childNodes' of null

this drives me crazy

like image 359
Eagle1 Avatar asked Dec 27 '22 01:12

Eagle1


1 Answers

Note that there is an error in your structure

<td></td>New account<td></td>

This text is not placed anywhere and could be causing the error in your full code.

It should probably be

<td></td><td>New account</td>

Demo With These Edits

like image 119
Travis J Avatar answered Feb 05 '23 16:02

Travis J