I have a tag <script>with the content in the element <div>. Now I need to copy / clone the content, save it in a variable and add it later.
Strange, when I add the contents of a variable, I just get external <div>.
Any idea what I'm doing wrong? We are using jQuery 1.8.2.
Here is my code:
html content:
<div id="payl">
<div class="toolTipHandler">
<script type="text/javascript">
var xxx_title = "<h4>title</h4>";
var xxx_text = "<p>bla bla</p>";
</script>
</div>
</div>
script.js:
var toolTipHandler = jQuery('#payl .toolTipHandler').clone(true);
document.getElementById('payl').innerHTML = '';
jQuery('#payl').append(toolTipHandler);
Result:
<div class="toolTipHandler"></div>
source
share