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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:07:59+00:00 2026-06-10T12:07:59+00:00

This example is from a book. It tells me that I can clone the

  • 0

This example is from a book.
It tells me that I can clone the paragraph without text if I set the parameter in the clone() to be false.
I checked out the documentation in the jQuery and I tried out all the combination of true and false.
The results proved that I cannot copy the paragraph without text.
Is it just a bug in jQuery?

<html>
    <head>
        <title>Copying element</title>
        <script src="../jquery-1.8.0.js" type="text/javascript"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                //copy elment and insert
                $('div.chapter p:eq(0)').clone(false).insertBefore('div.chapter');

            });
        </script>
        <style type="text/css">
            span.footnote{
                font-style:italic;
                display:block;
            }
            .chapter span.footnote{
                display:inline;
            }
            .chapter p{
                width:50%;
            }
        </style>
    </head>
    <body>
        <h1 id="f-title">Flatland: A ROmance of Many Dimension</h1>
        <div id="f-author">by Edwin A. Abbott</div>
        <h2>Part 1, Section 3</h2>
        <h3 id="f-subtitle">Concerning the Inhabitants of Flatland</h3>
        <div id="excerpt">an excerpt</div>
        <div class="chapter">
            <p class="squre">Our professional Men and Gentlemen are Squares (to which class I myself belong) and FIve-Sided Figures
                or Pentagons.
            </p>
            <p class="mobility hexagon">Next above these come the Nobility of whoem there are serverl degress
                <a href="http://en.wikipedia.org/wiki/Hexagon">Hexagons</a>and from thence rising in the number of theirside till they received the honourable title of 
                <a href="http://en.wikipedia.org/wiki/Polygon">Polygonal</a>
            </p>
            <p><span class="pull-quote">It is a <span class="drop">Law of Nature</span>with us that a mable child shall have </span>    
            </p>
            <p>But this rule applies not always to the Tradesman</p>
            <p>Rarely -- in proportion to the vast numbers of Isosceles
            </p>
            <p>The birth of tha Ture Equlaterial Traignel from Isoscele parents is the subject of rejociing in the coutry for many furlongs.
            </p>
            <p>How admirable is the Law of Compensation!
            </p>
        </div>
    </body>
</html>
  • 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-10T12:08:00+00:00Added an answer on June 10, 2026 at 12:08 pm

    Re-read the clone documentation.

    It specifies the element is copied WITH its content (deep copy). The boolean parameters only deals with event handlers and jquery data, not embedded elements.

    So this is the normal comportment : the first paragraph in div.chapter ($('div.chapter p:eq(0)')) is copied with its content.

    If you want a non-deep cloning function you could use this one :

    // clone an element with attributes, without the weight of calling clone and emptying it
    // (call it on a non jquery element, using  [0] if necessary)
    function nondeepclone(element) {
        var newelem = document.createElement(element.tagName);
        for (var i = 0; i < element.attributes.length; i++) {
            var attr = element.attributes[i];
            newelem.setAttribute(attr.name, attr.value);
        }
        return newelem;
    }
    

    but I’m not sure there is a real use for this.

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

Sidebar

Related Questions

thank you for looking i got this example from my book but i cant
This is an example from a book, a bit modified. It seems like sessions
This example was taken from Stroustup's book, third edition, Section 14.4.2 : void f
This example is from C++ templates book by Josuttis : #include <iostream> #include <cstring>
Consider this example from w3schools : <?xml version=1.0 encoding=ISO-8859-1?> <bookstore> <book category=COOKING> <title lang=en>Everyday
This example is taken from the Linux System Programming book, page 88. Code: http://pastebin.com/mEfmHbPP
I need help with this Java Program example. This example is from the book
I'm following Steve Sanderson's example from this ASP.NET MVC book on creating a model
I am trying to compile this code example from the book Head First C
These are example from a c# book that I am reading just having a

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.