Loading Please Wait...
The HTML DOM allows JavaScript to change the content of HTML elements.
The easiest way to modify the content of an HTML element is by using the innerHTML property.
<html>
<body>
<p id="p1">Hello World!</p>
<script>
document.getElementById("p1").innerHTML = "New text!";
</script>
</body>
</html>
To change the value of an HTML attribute, you can use attribute properties such as src, name, href, etc.
<html>
<body>
<img id="myImage" src="image-1.png">
<script>
document.getElementById("myImage").src = "image-2.png";
</script>
</body>
</html>
JavaScript can create dynamic HTML content.
<html>
<body>
<p id="myPara"></p>
<script>
document.getElementById("myPara").innerHTML = "Date : " + Date();
</script>
</body>
</html>
In JavaScript, document.write() can be used to write directly to the HTML output stream
<html>
<body>
<p>Paragraph 1</p>
<script>
document.write(Date());
</script>
<p>Paragraph 2</p>
</body>
</html>
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved