Get content of <section> tag including html tags and store it in a variable <p>Consider the following stripped down part of some html code:</p> <pre><code>&lt;section id ="test" contenteditable="true" ... &gt; &lt;h3&gt; This is a header &lt;/h3&gt; &lt;p&gt; Some stuff in here &lt;/p&gt; &lt;p&gt; Some more stuff here &lt;/p&gt; &lt;/section&gt; </code></pre> <p>How do I get the <code>&lt;h3&gt; and &lt;p&gt;</code> elements from the section and store it in a variable?</p> <p>E.g.</p> <pre><code>var result = "&lt;h3&gt; This is a header &lt;/h3&gt; &lt;p&gt; Some stuff in here &lt;/p&gt; &lt;p&gt; Some more stuff here &lt;/p&gt;" </code></pre> <p>Also is it possible to get linebreaks etc as well?</p> <p>I've tried using jquery <code>.val()</code> and JS <code>document.getElementByID(..)</code>, but they both return the section element altogether. </p>