Adding several new elements through the Append () and prepend () methods

Source: Internet
Author: User

In the example above, we only insert the text/html at the beginning/end of the selected element.

However, the Append () and prepend () methods can receive an unlimited number of new elements through parameters. You can use JQuery to generate text/html (as in the example above), or through JavaScript code and DOM elements.

In the following example, we create a number of new elements. These elements can be created by text/html, JQuery, or javascript/dom. We then append these new elements to the text (as valid for prepend () using the Append () method:

Instance
function AppendText () {var txt1= "<p>Text.</p>";               Create a new element in HTML var txt2=$ ("<p></p>"). Text ("text.");   Create new element var txt3=document.createelement ("P") with JQuery;  Create a new element in DOM txt3.innerhtml= "Text."; $ ("P"). Append (TXT1,TXT2,TXT3);         Append new Element}

Adding several new elements through the Append () and prepend () methods

Related Article

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.