HTML CSS Javascript jQuery AJAX PHP Java MORE

How to add HTML element using Javascript

We often need form data on the same page to send the data through AJAX. So in this example we will learn how to get value by Id Javascript.

<!DOCTYPE html>
<html>
	<body>
	<div id="new">
		<p id="p1">Student</p>
		<p id="p2">Tutorial</p>
	</div>
	<script>
		var para = document.createElement("p");
		var node = document.createTextNode("Student Tutorial is a online tutorial platform !");
		para.appendChild(node);
		var element = document.getElementById("new");
		element.appendChild(para);
	</script>
</body>
</html>


Run it yourself