I have created a <ul> which add <li> dynamically by a button with a remove button.
Initially the default li must not contain a remove so i added it in script
SCRIPT
$(document).ready(function(){
$("#add").click(function ()
{
$('.main').append('<br>');
$('.main').append($('.append_list').html());
$('.main').append("<button class='rmv_btn' style='clear:both'> Remove </button>");
});
$(".rmv_btn").click(function ()
{
$(this).remove("append_list");
//Also tried this $(this).closest('li').remove();
});
});
When i click the remove button that particular section only removed…..
HTML
<ul class="main" style="list-style-type:none;">
<li class="append_list">
<label>Product 1</label> <input type="text">
<br>
<label>Product 2</label> <input type="text">
<br>
<label>Product 3</label> <input type="text">
<br>
<label>Product 4</label> <input type="text">
<br>
</li>
</ul>
<button id="add" style="clear:both">ADD NEW PRODUCTS</button>-
Here I made a bin in this.
How can i make this??
NOTE
I have made this process but till its complecated for i want to place the remove button next to the first textbox created here…
Try this way,
Working demo
Updated Demo