Reputation: 2337
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 */
});
}
Upvotes: 0
Views: 142
Reputation: 6381
var $div = $("div[data-test=sectionA]");
var $strong = $('strong', $div).clone();
var $p = $('p', $div).clone();
Upvotes: 1