javascript - Jquery wrapInner not working on page -
i'm having issues wrapinner i've never seen before. page dynamically generated page, expected, , i'm trying wrap elements of div in table grid.
here's example of html code:
<div class="n-files-all" id="yw4"> <div class="yiipager"> <div class="n-file">content</div> <div class="n-file">content</div> <div class="n-file">content</div> </div> </div> here's javascript:
var checkexist = setinterval(function() { if ( icon_container.find(".n-file").length ) { // if there children, console.log("there n-files!"); $(".n-files-all .yiipager").wrapinner("<table id='mygrid' class='tablesorter'></table>"); clearinterval(checkexist); } }, 100); it's going if block because can put in send logs console , can see there.
i'm trying end should pretty simple (i wrap inner elements in tr , td):
<div class="n-files-all" id="yw4"> <div class="yiipager"> <table id="mygrid" class="tablesorter"> <div class="n-file">content</div> <div class="n-file">content</div> <div class="n-file">content</div> </table> </div> </div> here's kicker, if copy , paste code console, works , want to. going on? setinterval should work waiting content, tried $( document ).ready() wait whole document load.
thanks in advance!
more info:
so if append or prepend plain text div works. if try prepend or append html, not, it'll strip out html , leave text.
what if change the:
if ( icon_container.find(".n-file").length ) { to
if ( $('#yw4 .yiipager .n-file').length > 0 ) { anyway original seems valid, if assume icon_container defined.
Comments
Post a Comment