I like to append an li into an existing ul like here: jQuery: how to add <li> in an existing <ul>?
But in my code the li is an existing li from another html file. So 'm having the products.html with an ul. In this html file I like to append the li
<li class="first-li" id="hotel_belle">
<h2>Hotel Belle</h2>
<div>
<img class="sub-img" alt="picture from hotel" src="pic/products/HotelBelle.png" />
<p>Lorem Ipsum</p>
<a href="#"><img class="btn-cart" alt="add this product to cart" src="pic/book/cart.png" /></a>
</div>
</li>
into the cart.html:
<div id="inner-cart-content">
<ul id="content-cart">
<li>
//The new li element from products.html
in the JavaScript I wrote this:
$(".btn-cart").click(function(){
var cart = $(this).parents("li").eq(0);
//$("#inner-cart-content ul").append('cart'); <--this is not working
});
So what do I have to do?