Edit This Code:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
function prependText() {
    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
    $("p").prepend(txt1, txt2, txt3);       // Prepend new elements
}
</script>
</head>
<body>

<p>This is a paragraph.</p>

<button onclick="prependText()">Prepend text</button>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy