Open In App

HTML | DOM Emphasized Object

Improve
Improve
Like Article
Like
Save
Share
Report

The DOM Emphasized Object is used to represent the HTML <em> element. The Emphasized element is accessed by getElementById().
Syntax:

document.getElementById("ID");

Where “id” is the ID assigned to the “em” tag.

Example-1:




<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Emphasized Object</title>
</head>
  
<body>
    <center>
        <h2>DOM Emphasized Object</h2>
        
        <!--Text in Italics-->
        <p>Hello GeeksforGeeks</p>
        
        <!--Text in Emphasize-->
        <p><em id="GFG">Hello GeeksforGeeks</em></p>
        
        <button onclick="mygeeks()">
          Submit
        </button>
        
            <script>
                function mygeeks() {
                    var gfg = document.getElementById("GFG");
                    gfg.style.color = "red";
                    gfg.style.fontSize = "29px";
                }
            </script>
  </center>
</body>
  
</html>


Output:

Before Clicking On Button :

After Clicking On Button:

Example-2 :




<!DOCTYPE html>
<html>
  
<head>
    <title>DOM Emphasized Object</title>
</head>
  
<body>
    <h2>DOM Variable Object</h2>
    
    <!--Text in Paragraph-->
    <p>Hello GeeksforGeeks</p>
    
    <button onclick="mygeeks()">
      Submit
    </button>
    
        <script>
            function mygeeks() {
                var gfg = document.createElement("em");
                var text = 
                document.createTextNode("Hello GeeksForGeeks");
                gfg.appendChild(text);
  
                document.body.appendChild(gfg);
            }
        </script>
</body>
  
</html>


Output:

Before Clicking On Button:

After Clicking On Button:

Supported Browsers: The browser supported by DOM Emphasized Object are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari


Last Updated : 22 Jan, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads