原生js追加Html 或者text


方法:insertAdjacentHTML(postion,html);

   insertAdjacentTEXT(postion,text);

參數:

position 是相對於 element 元素的位置,並且只能是以下的字符串之一:

1. beforeBegin: 插入到標簽開始前

2. afterBegin:插入到標簽開始標記之后

3. beforeEnd:插入到標簽結束標記前

4. afterEnd:插入到標簽結束標記后

html 是 需要添加的標簽節點

text 是文本

參考地址:https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM