Search the Blog

Sunday, August 4, 2019

JavaScript DOM API for HTML and XML

DOM stands for Document Object Model. It is an object-oriented representation of structured documents like XML and HTML.


How to set the Text content of an element that will be appear on web browser is done by DOM API Property.
    Let us see the demo-
  <p  id="paragraph_1"></p>

Now what to show in this content is depend on the requirement, So with the help of JavaScript we can do this-
    Let see the Code-
document.getElementById("paragraph_1").textContent="Programming Logic and Code"



Demo Code Complete-

Html/JSP file Code 

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">

  <title>www.dizsweb.com</title>

</head>
<body>
<p id="paragraph_1"></p>
</body>
</html>


Javascript File Code
document.getElementById("paragraph_1").textContent = "Programming Logic and Code";


Output-   Programming Logic and Code



No comments:

Post a Comment

Translate