HTML | DOM Samp Object
The Samp Object in HTML DOM is used to represent the <samp> element. The <samp> element can be accessed by using getElementById() method.
Syntax:
document.getElementById("ID");
Where ID is assigned to the <samp> tag.
Example 1:
<!DOCTYPE html> <html> <head> <title> HTML DOM samp Object </title> </head> <body> <h1> GeeksforGeeks </h1> <h2> HTML DOM Samp Object </h2> <samp id = "geeks"> A computer science portal for Geeks </samp> <br><br> <button onclick = "myGeeks()"> Submit </button> <script> function myGeeks() { var txt = document.getElementById("geeks"); txt.style.color = "green"; txt.style.fontSize = "16px"; } </script> </body> </html> |
Output:
Before Click on the Button:

After Click on the Button :

Example 2: Samp Object can be created by using the document.createElement Method.
<!DOCTYPE html> <html> <head> <title> HTML DOM samp Object </title> </head> <body> <h1>GeeksForGeeks</h1> <h2>DOM Samp Object</h2> <button onclick = "myGeeks()"> Submit </button><br> <script> function myGeeks() { var cont = document.createElement("SAMP"); var txt = document.createTextNode( "A Computer SciencePortalForgeeks"); cont.appendChild(txt); document.body.appendChild(cont); } </script> </body> </html> |
Output:
Before Click on the Button :

After Click on the Button:

Supported Browsers: The browser supported by DOM Samp Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <samp> Tag
- HTML | DOM Object Object
- HTML | Object tag
- HTML DOM Aside Object
- HTML | DOM Del Object
- HTML | DOM DD Object
- HTML | DOM Kbd Object
- HTML | DOM BR Object
- HTML| DOM Ins Object
- HTML | DOM dl Object
- HTML | DOM Pre Object
- HTML | DOM Div Object
- HTML | DOM Ol Object
- HTML | DOM li Object
- HTML | DOM S Object
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

