Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing jQuery .append and .html together
    text
    copied!<p>I am having to add content dynamically to an iFrame that is generated by my CMS in their forum module. I have no control over the HTML. I am adding content dynamically and trying to find the best solution. </p> <p>Here is the code I am using: </p> <p><em><strong>HTML</em></strong></p> <pre><code>&lt;iframe id="re_contentIframe"&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt;Forum content is typed here.&lt;/p&gt; &lt;p&gt;More forum content.&lt;/p&gt; Forum Signature &lt;/body&gt; &lt;/html&gt; &lt;/iframe&gt; </code></pre> <p><em><strong>JS</em></strong></p> <pre><code>nestedFrame = myFrame.find('#re_contentIframe').contents().find('body'); nestedFrame.append("Dynamic content" + data); //this is what is inserted dynamically. </code></pre> <p>Here is the issue I run into. Because I cannot control the code for the iFrame my CMS generates because of this I end up having something like this when I use the above code: </p> <pre><code>Forum Signature Dynamic content... </code></pre> <p>I want the dynamic content to be added <em>below</em> the <code>Forum Signature</code>. I then tired this: </p> <pre><code>nestedFrame.html("Dynamic content" + data); //this is what is inserted dynamically. </code></pre> <p>When I do this the forum content is wiped by <code>.html</code></p> <p>I then tried this: </p> <pre><code>nestedFrame.append(" &lt;br&gt; Dynamic content" + data); </code></pre> <p>When I do that it prints the <code>&lt;br&gt;</code>. </p> <p>Here is my question: </p> <p>Is there a way to append html to the target without wiping the html that is there? I cannot figure a way to do this. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload