I have the following html content:
<div data-test='sectionA'>
<input type="text" />
<strong>sfdsfds</strong>
<p>dffdfdsf</p>
</div>
I need to clone only the strong and p elements from the html content above. Here is my attempt:
First I need to identify the section:
if($("div").data("test") == "sectionA")
{
$(this).children().not("input").each(function()
{
alert($(this).html().clone());
/* firefox says clone is not a function
and I'm not getting <strong>dfadfa</strong>
or the <p>sfdasdfsd</p> clone copy */
});
}
.html()returns a string. And you can only clone HTML elements, not strings. Try removing thathtmlfunction returns string not nodes/objects so you have nothing to clone.