how to capture the first cloned list using jquery?
<ul id=testList>
<li><input type=checkbox" /><p> Test A </p></li>
<li><input type=checkbox" /><p> Test B </p></li>
<li><input type=checkbox" /><p> Test C </p></li>
<li><input type=checkbox" /><p> Test D </p></li>
<li><input type=checkbox" /><p> Test E </p></li>
</ul>
My attempt:
var firstClonedList = $("#testList li:eq(0)").clone();
alert(firstClonedList.html());
Problem:
The alert is displaying:
<input type=checkbox" /><p> Test A </p>
correctly but I need the alert to display:
<li><input type=checkbox" /><p> Test A </p></li>
Your variable
firstClonedListlist contains what you need, but by adding.html()you are asking to give the html content of firstClonedList. So just use firstClonedList[0]