HTML DOM Bold Object
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: In this example, we will use HTML DOM Bold Object
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM Bold Object </ title > </ head > < body > < b ></ b > < h1 id = "GFG" >w3wiki</ h1 > < h2 style = "font-size:35px;" >DOM Bold Object</ h2 > < br > < button onclick = "myBeginner()" > Submit </ button > < p id = "Beginner" ></ p > < script > function myBeginner() { let b = document.getElementById("GFG"); b.style.backgroundColor = "red"; } </ script > </ body > </ html > |
Output:
Example 2: Bold Object can be created by using the document.createElement Method.
HTML
<!DOCTYPE html> < html > < head > < title > HTML DOM Bold Object </ title > </ head > < body > < h1 >w3wiki</ h1 > < h2 >DOM Bold Object</ h2 > < button onclick = "myBeginner()" > Submit </ button > < p id = "sudo" ></ p > <!-- script for Bold Object --> < script > function myBeginner() { let G = document.createElement("B"); let F =document.createTextNode("w3wiki"); G.appendChild(F); document.body.appendChild(G); } </ script > </ body > </ html > |
Output:
Supported Browsers: The browser supported by DOM Bold Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari