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