HTML DOM Cite ऑब्जेक्ट HTML <cite> एलिमेंट से जुड़ा होता है। <cite> एलिमेंट का उपयोग किसी रचनात्मक कार्य (creative work) का संदर्भ (reference) देने के लिए किया जाता है और इसमें शीर्षक (title) शामिल होना आवश्यक है। यह कोई पेंटिंग, किताब, टीवी शो, फिल्म आदि हो सकती है।
सिंटैक्स (Syntax)
Cite ऑब्जेक्ट बनाने का सिंटैक्स निम्नलिखित है:
var x = document.createElement("CITE");उदाहरण (Example)
आइए HTML DOM Cite ऑब्जेक्ट का एक उदाहरण देखते हैं:
<!DOCTYPE html> <html> <body> <p>CITE एलिमेंट बनाने के लिए नीचे दिए गए बटन पर क्लिक करें।</p> <button onclick="createCite()">CREATE</button><br><br> <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/800px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg" width="220" height="277" alt="The Starry night"> <script> function createCite() { var x = document.createElement("CITE"); var t = document.createTextNode("The Starry night."); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>आउटपुट (Output)
इससे निम्नलिखित आउटपुट प्राप्त होगा:

"CREATE" पर क्लिक करें:

उपरोक्त उदाहरण में हमने <img> टैग का उपयोग करके एक इमेज डाली है:
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/ea/Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg/800px-Van_Gogh_-_Starry_Night_-_Google_Art_Project.jpg" width="220" height="277" alt="The Starry night">
फिर हमने एक बटन CREATE बनाया जो createCite() मेथड को एक्जीक्यूट करता है:
<button onclick="createCite()">CREATE</button>
createCite() मेथड एक <cite> एलिमेंट बनाता है और इसे वेरिएबल x में असाइन करता है। कुछ टेक्स्ट वाला एक टेक्स्ट नोड बनाया जाता है और वेरिएबल t में असाइन किया जाता है। फिर appendChild() मेथड का उपयोग करके टेक्स्ट नोड को <cite> एलिमेंट में जोड़ा जाता है। अंत में, टेक्स्ट नोड के साथ <cite> एलिमेंट को document.body के appendChild() मेथड का उपयोग करके डॉक्यूमेंट बॉडी में जोड़ा जाता है।