HTML DOM Yuanxiu insertAdjacentText() fangfa
- Babban ɗanɗin insertAdjacentHTML()
- Babban ɗanɗin insertBefore()
- Rarrabu HTML DOM Elements ɗanɗin
dingyi he yongfa
insertAdjacentText()
fangfa jiang wenzi ruxian zhi zhiding weizhi.
hege de weizhi:
zhi | miaoshu |
---|---|
afterbegin | zai yuanxiu kaishi zhi hou (di yi ge zi xu yuanshi). |
afterend | yuanxiu hou. |
beforebegin | yuanxiu qian. |
beforeend | zai yuanxiu jieshu zhi qian (zui hou ge zi xu yuanshi). |
shi li
li ti 1
zai biaoti yuanxiu hou ruxian wenzi:
const h2 = document.getElementById("myH2"); let text = "My inserted text"; h2.insertAdjacentText("afterend", text);
li ti 2
shi yong "afterbegin":
const h2 = document.getElementById("myH2"); let text = "My inserted text"; h2.insertAdjacentText("afterbegin", text);
li ti 3
shi yong "beforebegin":
h2.insertAdjacentText("beforebegin", text);
li ti 4
shi yong "beforeend":
h2.insertAdjacentText("beforeend", text);
yufa
element.insertAdjacentText(weizhi, text)
haya
node.insertAdjacentText(weizhi, text)
canju
canju | miaoshu |
---|---|
weizhi |
yixu. Xiangdui yuanxiu de weizhi:
|
text | a baiya a ruxian. |
sududu kai dake
kukun kai dake sujudu element.insertAjacentText()
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Gudanarwa | Gudanarwa | Gudanarwa | Gudanarwa | Gudanarwa | Gudanarwa |
- Babban ɗanɗin insertAdjacentHTML()
- Babban ɗanɗin insertBefore()
- Rarrabu HTML DOM Elements ɗanɗin