HTML DOM सम्मिलित करेंAdjacentText () विधि
उदाहरण
निर्दिष्ट हेडर तत्व के बाद टेक्स्ट डालें:
var h = document.getElementById("myH2");
h.insertAdjacentText("afterend",
"My inserted text");
परिभाषा और उपयोग
insertAdjacentText()
विधि निर्दिष्ट तत्व को निर्दिष्ट स्थिति में सम्मिलित करती है ।
कानूनी स्थिति मान हैं:
"बाद में" "बाद में"
"पहले से शुरू
"
"पहले से"
ब्राउज़र समर्थन
तालिका में संख्याएं पहले ब्राउज़र संस्करण को निर्दिष्ट करती हैं जो पूरी तरह से विधि का समर्थन करता है।
Method | |||||
---|---|---|---|---|---|
insertAdjacentText() | Yes | Yes | 48 | Yes | Yes |
वाक्य - विन्यास
node.insertAdjacentText(position, text)
पैरामीटर मान
Parameter | Type | Description |
---|---|---|
position | String | Required. A position relative to the element. Legal values: "afterbegin" - After the beginning of the element (as the first child) "afterend" - After the element "beforebegin" - Before the element "beforeend" - Before the end of the element (as the last child) |
text | String | The text you want to insert |
और ज्यादा उदाहरण
उदाहरण
"आफ्टरबीन" मान का उपयोग करना:
var h = document.getElementById("myH2");
h.insertAdjacentText("afterbegin",
"My inserted text");
उदाहरण
"पहले से शुरू" मान का उपयोग करना:
var h = document.getElementById("myH2");
h.insertAdjacentText("beforebegin",
"My inserted text");
उदाहरण
"पहले से" मान का उपयोग करना:
var h = document.getElementById("myH2");
h.insertAdjacentText("beforeend",
"My inserted text");