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 8446993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:04:30+00:00 2026-06-10T10:04:30+00:00

I have a nested UL LI list. e.g. BEFORE <ul> <li>Item A</li> <li>Item B

  • 0

I have a nested UL LI list. e.g.

BEFORE

<ul>
    <li>Item A</li>
    <li>Item B
        <ul>
            <li id="removeme">Item BA (REMOVE ME)
            <ul>
                <li>Item BAA</li>
                <li>Item BAB</li>
                <li>Item BAC</li>
                <li>Item BAD
                    <ul>
                    <li>Item BADA</li>
                    <li>Item BADB</li>
                    <li>Item BADC</li>
                    <li>Item BADD</li>
                    </ul>                 
                </li>
                <li>Item</li>
            </ul>            
            </li>
            <li>Item BB</li>
            <li>Item BC </li>
            <li>Item BD</li>
        </ul>
    </li>
    <li>Item C</li>
    <li>Item D</li>
    <li>Item E</li>
</ul>

AFTER :

<ul>
    <li>Item A</li>
    <li>Item B
        <ul>
            <li>Item BAA</li>
            <li>Item BAB</li>
            <li>Item BAC</li>
            <li>Item BAD
                <ul>
                <li>Item BADA</li>
                <li>Item BADB</li>
                <li>Item BADC</li>
                <li>Item BADD</li>
                </ul>                 
            </li>
            <li>Item</li>           
            </li>
            <li>Item BB</li>
            <li>Item BC </li>
            <li>Item BD</li>
        </ul>
    </li>
    <li>Item C</li>
    <li>Item D</li>
    <li>Item E</li>
</ul>

If i wanted to remove the item above in the brackets (or anyitem) by double clicking it for example and remove it from the list however preserving the children elements and re-parenting them. how would you do this? i am working on a navigation manager and need to be able to delete items but not the children and have them re-parented.

Any cluees would be great.

I’ve though about getting all children of current element the append to current items parent. But that would duplicate the ul.

Thanks

*UPDATED TO INCLUDE BEFORE AND AFTER EXAMPLES

  • 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-10T10:04:32+00:00Added an answer on June 10, 2026 at 10:04 am

    If the target element that you want to do this operation on is elem, then you can do this:

    $(elem).find("li").insertAfter(elem);
    $(elem).remove();
    

    Example here: http://jsfiddle.net/jfriend00/RrHB2/

    To hook this up to a dlbclick event, it would look something like this (where you fill in the appropriate selector to target the right items):

    $(selector).dblclick(function(e) {
        e.stopPropagation();
        var target = $(this);
        target.find("li").insertAfter(item);
        target.remove();
    });
    

    If you want to support multiple levels and only collapse one level, then you could use this:

    var target = $("#removeme");
    target.children("ul").children().insertAfter(target);
    target.remove();
    

    or

    $(selector).dblclick(function() {
        e.stopPropagation();
        var target = $(this);
        target.children("ul").children().insertAfter(target);
        target.remove();
    });
    

    Working demo: http://jsfiddle.net/jfriend00/TbDY7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nested list of data. Its length is 132 and each item
I have nested list of the following form: my_list = [['Some1', '2', '3.6', '4.5',
I have a nested list like this: <ul class=list> <li class=list_item_type_1> <ul class=list> <li
I have a nested list comprising ~30,000 sub-lists, each with three entries, e.g., nested_list
I have a nested list something like this: PLACES = ( ('CA', 'Canada', (
I have Python nested list that I'm trying to organize and eventually count number
I have a nested unsorted list and I want to place a click event
I have a nested oredered list which i m animating using this code... var
I have a nested ul/li list <ul> <li>first</li> <li>second <ul> <li>Third</li> </ul> </li> ...
I have to calculate the average of each column in a specific nested list

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.