Javascript examples for jQuery Method and Property:append
Add HTML, jQuery DOM and Javascript DOM
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> function appendText() {/*w w w . jav a2 s . c om*/ var txt1 = "<p>plain html.</p>"; // Create text with HTML var txt2 = $("<p></p>").text("jQuery dom"); // Create text with jQuery var txt3 = document.createElement("p"); txt3.innerHTML = "Javacript DOM."; // 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>