The DOM Cite Object is used to represent HTML <Cite> element. The Cite element is accessed by getElementById().
Syntax:
document.getElementById("id");
Where “id” is the ID assigned to the cite tag.
Example 1: In this example, we will use DOM Cite Object
HTML
<!DOCTYPE html>
< html >
< head >
< title >DOM cite Object</ title >
< style >
body {
text-align: center;
}
</ style >
</ head >
< body >
< img src =
alt = "gfg" >
< p >< cite id = "GFG" >GeeksforGeeks Image</ cite ></ p >
< button onclick = "Geeks()" >Submit</ button >
< script >
function Geeks() {
let w = document.getElementById("GFG");
w.style.color = "coral";
w.style.fontWeight = "bold";
}
</ script >
</ body >
</ html >
|
Output:
Example-2: Cite Object can be created by using the document.createElement method.
HTML
<!DOCTYPE html>
< html >
< head >
< title >DOM cite Object</ title >
< style >
body {
text-align: center;
}
</ style >
</ head >
< body >
< h2 >DOM Cite Object</ h2 >
< button onclick = "Geeks()" >
Submit
</ button >
< img src =
alt = "gfg" >
< script >
function Geeks() {
let cite = document.createElement("CITE");
let text =
document.createTextNode("GeeksforGeeks Image");
cite.appendChild(text);
document.body.appendChild(cite);
}
</ script >
</ body >
</ html >
|
Output
Supported Browsers: The browser supported by DOM Cite Object are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari