Answer the question
In order to leave comments, you need to log in
Why are cloned elements not removed?
Good afternoon!
Please help me solve the following problem.
tennis-play.web-volodin.ru/reg2.html
At the end of the form there is a field for the social network. There is an "add another link" link that clones the field:
$('.newverstka .tournaments-page .reg-block form .field a.add').click(function() {
$(this).parent().parent().prev('.soc').find('.social:first-child').clone().appendTo('.field.soc');
});
$('.newverstka .tournaments-page .reg-block form .field .social .delete').click(function() {
$(this).parent().remove();
});
Answer the question
In order to leave comments, you need to log in
When an element is cloned, the events attached to it are not copied to the new element. Use event bubbling.
$('.newverstka .tournaments-page .reg-block form .field').on('click', '.social .delete', function() {
$(this).parent().remove();
});
.clone(true)
The call is not right, try this (it worked in the browser)
$('.social .delete').click(function() {
$(this).parent().remove();
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question