HTML DOM स्मॉल ऑब्जेक्ट HTML एलिमेंट से जुड़ा है। हम क्रमशः createElement () और getElementById () विधि का उपयोग करके छोटे तत्व बना और एक्सेस कर सकते हैं।
सिंटैक्स
−
. के लिए वाक्य रचना निम्नलिखित हैछोटी वस्तु बनाना -
var s= document.createElement("SMALL"); उदाहरण
आइए हम छोटी वस्तु के लिए एक उदाहरण देखें -
<!DOCTYPE html>
<html>
<body>
<h1>Small object example</h1>
<p>Create a small element containing some text by clicking the below button</p>
<button onclick="CreateSmall()">CREATE</button>
<p>This is normal text</p>
<script>
function CreateSmall() {
var s = document.createElement("SMALL");
var txt = document.createTextNode("This is small text");
s.appendChild(txt);
document.body.appendChild(s);
}
</script>
</body>
</html> आउटपुट
यह निम्नलिखित आउटपुट देगा -

क्रिएट बटन पर क्लिक करने पर -
