Why is AppendChild not working!



We are trying to create 2 DIVs, append the 2nd created DIV into 1st created DIV and append the whole thing into the static DIV. The Append works fine in case of Appending the 1st created DIV into the static DIV but not in case of appending the created DIV into created DIV. As you can see here:


by clicking on: Show All

It produces JS Error message:

Uncaught TypeError: Cannot read property 'appendChild' of null

Even though the DIV is created and defined via:

newNode.innerHTML = res_list[indx];
newNode.className = ('flat_top w3-animate-left bott_container');  
newNode.id = idval;

What is the fix to this?



Hi there WorldNews,

you need to swap the code on lines #775 and #777 around. :winky:

So instead of ...



...it should be...


Also note that the "Web Console" points out that your code is
missing these two functions...

function display_div() {
    // your code here

function close_div() {
    // your code here




Yes that lil change takes care off the problem. Thanks.
And function display_div() {
// your code here
are loaded via an external js file.



        No problem, you're very welcome. :winky:

closed #5

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.