Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7789863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:25:22+00:00 2026-06-01T21:25:22+00:00

My demo, is really clear, when I clone my element I clone and delete

  • 0

My demo, is really clear, when I clone my element
I clone and delete the divs however, the :last element (li) should’t been removed.
what I’m missing?

is something to do with this!:

$(document).on("click", 'li.delete',function () {
            $(this).closest(".outerDiv").remove();
    if ($(this).is(".outerDiv:last")){
            return false;
    }

DEMO:
http://jsfiddle.net/XeELs/86/

JQUERY
var cloneCount = 0;
$(“#add-address”).click(function() {

    $("#to-add-address").clone()
        .attr("id", "to-add-address_Clone" + cloneCount)
        .insertAfter("#to-add-address");
    $("#clone", "#to-add-address_Clone" + cloneCount)
        .attr("id", "clone_Clone" + cloneCount);
    cloneCount++;
});

$(document).on("click", '.options li a',function () {
            $(this).closest(".options").find('li a').removeClass('selected');
            $(this).addClass('selected');

        });
$(document).on("click", 'li.delete',function () {
            $(this).closest(".outerDiv").remove();
    if ($(this).is(".outerDiv:last")){
            return false;
    }

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:25:23+00:00Added an answer on June 1, 2026 at 9:25 pm

    try this code

    var cloneCount = 0;
    $("#add-address").click(function() {
    
        $("#to-add-address").clone()
            .attr("id", "to-add-address_Clone" + cloneCount)
            .insertAfter("#to-add-address").addClass('cloned');  //add a new class cloned to the cloned outerDivs
        $("#clone", "#to-add-address_Clone" + cloneCount)
            .attr("id", "clone_Clone" + cloneCount);
        cloneCount++;
    });
    
    $(document).on("click", '.options li a',function () {
                $(this).closest(".options").find('li a').removeClass('selected');
                $(this).addClass('selected');
    
            });
    $(document).on("click", 'li.delete',function () {
                $(this).closest(".outerDiv").filter('.cloned').remove(); // and delete only the cloned ones
        if ($(this).is(".outerDiv:last")){
                return false;
        }   
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really like Demo#3 on this page: http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm However I'd like to place text
This has been really killing me for the last couple of days now. I
This is a really strange behavior, and I've set up some demo code to
I'm really struggling with this. I have a flash demo built in AS2 (not
I am stumped and could really use some help with this gallery I've been
This thing really bugs me: on http://view.jquery.com/trunk/plugins/autocomplete/demo/ , how come the text in the
please see the demo below : http://www.templateaccess.com/demos/walkin/ i bought this template and really really
http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side
see this demo from jquery ui you have to hold down the Ctrl key
What Windows Phone 7 demo/reference applications have you seen which really made you interested

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.