javascript - Rails + JQuery: Getting to a sibling div from script -


i have rails partial renders html:

<div class="content"></div> <script>     // load content here , adjacent div , populate it. </script> 

this partial template gets embedded in main document server , several times response ajax requests. page has several instances of partial.

whenever script executes want div adjacent script affected.

so hoping if script, can div. use jquery , use several async scripts (this prevents me using last executed script)

i adjacent div through document.currentscript , problem browsers don't support it.

then, way create sort of uuid id div , access id dom?

i wished div supported onload, sadly not.

you can create element after <script> (document.write) , find .content relative it.

(function(){   var id = 'id' + (new date().gettime());    document.write('<div id="'+id+'"></div>');    var elem = document.getelementbyid(id);   var content = elem.previouselementsibling.previouselementsibling;    content.innerhtml = 'new content'; })(); 

example jsbin


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -