Reputation: 91
I've been trying to get all the markup between li tags and move it to another div on the page. I have tried using html, innerhtml, and children. But, it just returns [object Object]...
The html (highly modified for simplicity):
<ul>
<li class="add">I want this</li>
<li class="add">I don't want this</li>
</ul>
<div id="second">
<!-- i want to insert here -->
</div>
This is the most current iteration of jQuery code...
$('li.add').click(function() {
var thisitem = $(this).html();
$("#selections").append(thisItem);
});
Upvotes: 2
Views: 5948
Reputation: 11
you can try this also.. but dont forget to include jquery library.
<script>
$(document).ready(function(){
var tr3 = $(".add li").eq(1).html();
var tr4 = $(".add li").eq(2).html();
$("#second ").html('<ul>'+ tr3 +'</ul><ul>'+ tr4 +'</ul>');
$(".add li").eq(1).hide();
$(".add li").eq(2).hide();
});
</script>
Upvotes: 1
Reputation: 42808
$('li.add').click(function() {
var thisitem = $(this).html();
$("#second").append(thisitem);
});
Upvotes: 1