v1study.com


Code <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
function appendText(){
var txt1 = "<p>Text1</p>"; //Tạo phần tử mới bằng HTML
var txt2 = $("<p></p>").text("Text2"); //Tạo phần tử mới bằng jQuery
var txt3 = document.createElement("p");
txt3.innerHTML = "Text3"; //Tạo phần tử mới bằng DOM
$("section").prepend(txt1, txt2, txt3); // Append new elements
}
</script>
</head>
<body>
<section style="color:red; font-weight:bold;">v1study.com</section>
<button onclick="appendText();">Prepend text</button>
</body>
</html>