js:插入

  • appendChild

parentElement.appendChild(newElement)

  • insertBefore

var insertedElement = parentElement.insertBefore(newElement, referenceElement);

  • innerHTML

element.innerHTML=''

  • insertAdjacentHTML
.insertAdjacentHTML("beforeBegin", ...)	before
.insertAdjacentHTML("afterBegin", ...)	prepend
.insertAdjacentHTML("beforeEnd", ...)	append
.insertAdjacentHTML("afterEnd", ...)	        after
  • insertAdjacentText

与前面的相同,但firefox不支持

你可能感兴趣的:(js)