天天看点

insertAdjacentHTML用法(真鸡儿难记)

insertAdjacentHTML 方法:在指定的地方插入html标签语句

原型:insertAdjacentHTML(swhere,stext)

参数:

swhere: 指定插入html标签语句的地方,

stext:要插入的内容

有四种值可用:

1.     beforeBegin: 插入到标签开始前——————beforeBegin<div>文本</div>

2.     afterBegin:插入到标签开始标记之后——————<div>afterBegin文本</div>

3.     beforeEnd:插入到标签结束标记前———————<div>文本beforeEnd</div>

4.     afterEnd:插入到标签结束标记后——————<div>文本</div>afterEnd

转载于:https://www.cnblogs.com/island1994/p/9211467.html