elementUtil.js 486 Bytes
Newer Older
Nature's avatar
Nature committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
export default{
  createElement: function (marker, tag) {
    let el = document.createElement(tag || 'div')
    el.setAttribute(marker, '')
    document.body.appendChild(el)
  },

  removeElement: function (marker) {
    let el = document.querySelector(marker) || document.querySelector(`[${marker}]`)
    if (el) { document.body.removeChild(el) }
  },
  timeout: function (duration = 0) {
    return new Promise((resolve, reject) => {
      setTimeout(resolve, duration)
    })
  },
}