I am trying to clone a row into content by creating unique ID yet I am facing some issues.
HTML:
<div class="content">
<div id="email-container" class="email-container">
<input type="text" value="" placeholder="Email">
<input type="text" value="" placeholder="Email">
<input type="text" value="" placeholder="Email">
<span class="plus-button">+</span>
</div>
</div>
JavaScript:
$('.plus-button').click(function(){
$('.email-container').clone().insertAfter(".email-container").end();
$('.email-container').find('.plus-button').text('-').not(':last-child');
});
Please find my fiddle below:
http://jsfiddle.net/meetravi/GCRVS/3/
I am trying to clone #email-container and add it inside .content with clearing the textbox values and also need to change the .plus-button value to “-” except the last row.
This should do the trick.
TIPP: When you are creating new elements in your DOM you should bind the item manually or use “on”
EDIT: Removed .live() because of its deprecation