Reputation: 451
I have my code here http://jsfiddle.net/NT4Zr/5/
In above code i am able to add new row but cant delete added row by clicking Delete link. How can i do that?
In hobbies section i want to add hobbies by writing into text box and add hobby button and it should be reflected to label
<label>Your Hobbies:</label>
and by clicking delete button it should be deleted.
How can i do that?
Please refer this link
as it works well but when i am adding school by typing school name and selecting year it will add new elements with same name. how can i create blank elements like this http://viralpatel.net/blogs/demo/dynamic-add-delete-row-table-javascript.html
How can i pass textbox value to the label in hobby section?
Upvotes: 0
Views: 670
Reputation: 5604
Working example using delegate
here: http://jsfiddle.net/jkeyes/KYrAE/1/
$("#Education").delegate(".deleteEl a", "click", function(){
$(this).parent().parent().remove();
});
delegate
is more efficient than live
.
Upvotes: 1
Reputation: 52769
As the element does not exist when you bind the click event, it is not associated. You need live to bind the event to dynamic elements.
$('.deleteEl a').live('click', function () {
$(this).parent().parent().remove();
});
Upvotes: 1