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

  • Home
  • SEARCH
  • 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 9196773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:55:27+00:00 2026-06-17T21:55:27+00:00

I have a div that I fetch dynamically and it is structured as below.

  • 0

I have a div that I fetch dynamically and it is structured as below.

      <div id="mainWrap">
            <div style="z-index: 1001; height: 407px; width: 328px; top: 150px; left: 601.5px;" id="com-TMRJDOR2KOET3X6JPV6XGU0FB7RGJ926" class="textBox contentBox">
               <div style="" class="editable"><p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, </p>
               </div>
            </div>

            <div style="z-index: 1002; height: 616px; width: 288px; top: 29px; left: 3.5px;" id="com-UPWTMKZ7OUTN8KG2JEK47LNPN5JO261H" class="textBox contentBox">
               <div style="" class="editable"><p>
            ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
              </div>
           </div>            
      </div>

Now,I want to remove the ids of all the children which I achieved like this.

      var getContent = $('#mainWrap');
      var finalContent = getContent.clone().children().removeAttr('id');
      var saveContent  = finalContent.parent().html();

But I get the inner div’s with out the outermost div i.e mainWrap.I also want the mainWrap div to be returned in the html I get.

This is what I tried to do,worked to some extent:

    $.fn.getOuter = function(val){
      return $('<div class="temp">').append($('#'+val).clone()).html();
    }
    var htmlPage = $.fn.getOuter('mainWrap');

If I do alert(htmlPage) I get the entire content.But when I try to remove the id attributes using this var content=$(htmlPage).children().removeAttr('id'); I don’t get the correct HTML.I still get only the children inside mainWrap.I am not sure where am I wrong.Any help would be appreciated.
Thanks for your time.

  • 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-17T21:55:28+00:00Added an answer on June 17, 2026 at 9:55 pm

    The problem is because when you do .parent() in final content, there is no parent as you’ve cloned the element into memory. Instead, wrap it in another div and get the html() of that. I have also amended the logic slightly, try this:

    var $getContent = $('#mainWrap').clone();
    $getContent.children().removeAttr('id');
    var saveContent  = $getContent.wrap('<div></div>').parent().html();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div that expands to the height of it's content. It works
I have a script that will fetch data from server and compose a DIV
I have a div that I click on to drag it. Once it's on
I have a div that will serve as container to other element, I have
I have a div that contains a list of messages (it's a chatroom application).
I have a div that is position: absolute and it contains items that get
I have a div that is absolutely positioned from the top left corner of
I have a div that has a one pixel solid white border on the
i have a div that it have image content .i wanna implement animation when
I have a DIV that I want to touch the bottom of the screen

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.