jQuery prepend()
insert created HTML element
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"> </script>/*from w w w . j a va2 s.c om*/ <script> function prependText() { let txt1 = "<p>Text.</p>"; let txt2 = $("<p></p>").text("Text."); let txt3 = document.createElement("p"); txt3.innerHTML = "Text."; $("p").prepend(txt1, txt2, txt3); } </script> </head> <body> <p>This is a paragraph.</p> <button onclick="prependText()">Prepend text</button> </body> </html>