Skip to content
Related Articles

Related Articles

Improve Article
HTML | DOM Bold Object
  • Last Updated : 14 Jan, 2019

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

document.getElementById("ID");

Where “id” is the ID assigned to the “b” tag.
Example-1:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Bold Object
    </title>
  
    <script>
        function myGeeks() {
            var b = document.getElementById("GFG");
            b.style.backgroundColor = "red";
        }
    </script>
</head>
  
<body>
    <b></b>
    <h1 id="GFG">GeeksForGeeks</h1></b>
    <h2 style="font-size:35px;">DOM Bold Object</h2>
    <BR>
    <button onclick="myGeeks()">
        Submit
    </button>
  
    <p id="geeks"></p>
</body>
  
</html>

Output:
Before Clicking On the Button:

After Clicking on Button:

Example-2: Bold Object can be created by using the document.createElement Method.




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Bold Object
    </title>
  
    <!-- script for  Bold Object -->
    <script>
        function myGeeks() {
            var G = document.createElement("B");
            var F = 
            document.createTextNode("GeeksForGeeks");
            G.appendChild(F);
            document.body.appendChild(G);
        }
    </script>
</head>
  
<body>
    <H1>GeeksForGeeks</H1>
    <h2>DOM Bold Object</h2>
  
    <button onclick="myGeeks()">
        Submit
    </button>
  
    <p id="sudo"></p>
  
</body>
  
</html>                  

Output:
Before Clicking on Button:

After Clicking on Button:

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

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :