javascript - Delete multiple Inputs on click with JS -
i paginated project (endless, without click) , when next page loaded, input select2 input
field in modal getting replicated. after bit of scrolling have couple duplicates.
so tried delete duplicates like:
$(".modalopen").click(function(){ $('.thelangu1:eq(0)').next("span").remove(); $('.thelangu1').children().find(...).remove(); $('.thelangu1:eq(1)').remove(); ... })
but nothing worked. code looks in console:
so first 1 needs stay alive rest has removed. ($('.thelangu1:eq(0)').remove();
remove except 1 deletes necessary 1 not help).
another problem have multiple <input>
, other select2
fields not done removing (i tried). needs in direction $(".thelangu1").children().find/next...
any jquery expert here tell me how remove duplicates or inputs except first one?
you can use not
css psuedo-selector
$('.thelangu1').parent() .find(".thelangu1:not('.thelangu1:first-child')") .remove();
you can use not
jquery method
$('.thelangu1').parent() .find(".thelangu1").not(".thelangu1:first-child") .remove();
Comments
Post a Comment