javascript - Change DIV in one remove/append -
here doing, create div structure dynamically
var divt = $('<div id="toplevel"></div>'); divt.append('<div id="child1"><div class="content1"></div></div>'); divt.append('<div id="child2"><div class="content1"></div></div>'); i store clone separate node , add dom.
this.emptydivt = $(divt).clone(); maindiv.append(divt); later on in code want replace contents of top level div using 1 remove/append.
firstly create new node saved...
this.newdivt = this.emptydivt.clone(); here want child divs , append new content , have tried various function can't work eg.
var childdiv = this.newdivt.find('#child1').html(); childdiv.append('<div> new content</div>'); then after replace top level div
maindiv.remove('#toplevel'); maindiv.append(this.newdivt); so there way child div jquery or js node not in dom ?
i see 2 typos in code, not sure if on real code not present
this.newdivt = this.emptydivt.clone(); // missed () and
var childdiv = this.newdivt.find('#child1').html(); // missed '' around #child1 also, code not valid clone doesn't accept jquery object parameter
this.emptydivt = $(eventgrid).clone(divt); maybe want divt.clone()?
edit
remove white spaces on elements ids white spaces not allowed on id attribute.
Comments
Post a Comment