javascript - Error: Failed to execute 'appendChild' on 'Node': The new child element contains the parent -


below code throws error when script running. code adding more menu. when run script throws error

failed execute 'appendchild' on 'node': new child element contains parent.

$(document).ready(function() {   ulnodes = document.getelementbyid("sub");   linodes = [];   (var = 0; < ulnodes.childnodes.length; i++) {     if (ulnodes.childnodes[i].nodename == "li") {       mpdata = ulnodes.childnodes[i].getattribute('class');       ulnodes.childnodes[i].setattribute('class', 'n-menu' + "  " + mpdata);       linodes.push(ulnodes.childnodes[i]);     }   }   var inp = document.getelementbyid("sub");   tot_li = inp.getelementsbyclassname("n-menu").length;   var n;   wwidth = window.innerwidth;   if ((wwidth > 767) && (wwidth < 800)) {     n = 4;   }   if ((wwidth > 800) && (wwidth < 1024)) {     n = 5;   }   if (wwidth > 1025) {     n = 7;   }   if (tot_li > n) {     mymore();   }    function mymore() {     myul = document.getelementbyid("sub");     myli = document.createelement("li");     myul.appendchild(myli);     myli.setattribute('id', 'more');     submore = document.getelementbyid("more");     subal = document.createelement("a");     subal.setattribute('href', '#nogo');     subal.innerhtml = "more";     submore.appendchild(subal);     subul = document.createelement("ul");     submore.appendchild(subul);     subul.setattribute('id', 'moreul');     var mrul = document.getelementbyid("moreul");     var old_li = document.getelementsbyclassname("n-menu");     v = old_li.length;     nw_li = [];     (var = v; > n; i--) //i=8    i>6     {       v = v - 1;       mrul.appendchild(old_li[v]);     }   } }); 


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -