The example in this article describes how jQuery uses append to add multiple contents at the same time after the html element. Share it with everyone for your reference. The specific analysis is as follows:
The following code can add multiple contents after a text paragraph at the same time
<!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> function appendText() { var txt1="<p>Text.</p>"; // Create text with HTML var txt2=$("<p></p>").text("Text."); // Create text with jQuery var txt3=document.createElement("p"); txt3.innerHTML="Text."; // Create text with DOM $("body").append(txt1,txt2,txt3); // Append new elements } </script> </head> <body> <p>This is a paragraph.</p> <button onclick="appendText()">Append text</button> </body> </html>
I hope this article will be helpful to everyone’s jQuery programming.