The cloning method of jquery clone ()

Source: Internet
Author: User

There are many places where clones are used in Web pages, such as the dynamic loading of content when the page scrolls to the bottom, which can be implemented using clones.

Cloning usually first put out the template separately, and set the style to Display:none, with the jquery clone () implementation

1         <Divclass= "Panel Panel-default clone-box">2             <Divclass= "Panel-heading">3                 <ahref= "javascript:;"class= "Flex">4                     <Divclass= "Panel-title">5                         <span></span>6                         <imgsrc= "Img/work2.jpg"class= "Work1">7                     </Div>8                 </a>9             </Div>Ten             <Divclass= "Panel-collapse collapse"> One                 <Divclass= "Panel-body"> A                     <P>Completed today</P> -                     <Pclass= "Finish-detail"></P> -                     <P>Difficulty or summary</P> the                     <Pclass= "Summary">None, if there can be written!</P> -                 </Div> -             </Div> -         </Div>
1 . cone-box{2    display:none; 3 }

Next is the play, The Clone () method of jquery:

1 var clone = $ (". Clone-box"). Clone (true); 2 clone.removeclass ("Clone-box"); 3 $ (this). attr ("Data-dismiss", "modal");                                         4 $ ('. Weekbao. Panel-group '). prepend (clone);

True in the Clone () method means that even events are cloned together when cloning.

The cloning method of jquery clone ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.