Loading Please Wait...
JavaScript can display data or output in many different ways:
JavaScript may start executing its code at the moment we visit the website and the web page begins to load.
So when JS code finishes execution, we have processed data, and most of the time this updated data need to be changed on the web page.
The innerHTML property defines the HTML content of the element. We can select element by id attribute, class attribute, etc.
The innerHTML property is normally used when we want to change content of the element.
<!DOCTYPE html>
<html>
<body>
<h1>innerHTML Demo</h1>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>
</body>
</html>
The document.write() method writes data inside HTML by deleted existing content.
<!DOCTYPE html>
<html>
<body>
<h1>document.write() Demo</h1>
<button onClick="document.write(5 + 6)">Click Me</button>
</body>
</html>
The alert() method show an alert box and can be used to show data.
<!DOCTYPE html>
<html>
<body>
<h1>alert() Demo</h1>
<script>
alert(5 + 6);
</script>
</body>
</html>
The console.log() method display data in browser console.
<!DOCTYPE html>
<html>
<body>
<h1>console.log() Demo</h1>
<script>
console.log(5 + 6);
</script>
</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