What are alternatives to [removed]?

后端 未结 10 2209
北荒
北荒 2020-11-22 05:11

In tutorials I\'ve learnt to use document.write. Now I understand that by many this is frowned upon. I\'ve tried print(), but then it literally sen

10条回答
  •  我在风中等你
    2020-11-22 05:32

    You can combine insertAdjacentHTML method and document.currentScript property.

    The insertAdjacentHTML() method of the Element interface parses the specified text as HTML or XML and inserts the resulting nodes into the DOM tree at a specified position:

    • 'beforebegin': Before the element itself.
    • 'afterbegin': Just inside the element, before its first child.
    • 'beforeend': Just inside the element, after its last child.
    • 'afterend': After the element itself.

    The document.currentScript property returns the

提交回复
热议问题