init-with-dom

1.2.5 • Public • Published

IWD (init with DOM) NPM version

About

This script performs the function with the name specified in the attribute of the dom element in the context of this item.

Supported the start of the function even if the DOM Element has been added after initialization of the script (MutationObserver).

Browser

  • IE 10+
  • Edge
  • Firefox 14+
  • Chrome 18+
  • Safary 6+
  • Opera 15+
  • iOS Safari 6.1+
  • Android Browser 4.4 +

Usage

<div data-js="time" data-name="Hi" id="megaId"></div>
<script>
  function time (params) {
    var self = this; // DOM Element <div data-js="time"></div>
    var seconds;

    params; // { data: { name: "Hi" }, class: "js", id: "megaId" }

    setInterval(function () {
      var dt = new Date();

      if (seconds !== dt.getSeconds()) {
        self.innerText = dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds();
      }
      seconds = dt.getSeconds();
    }, 100)
  }
</script>
<script src="../build/iwd.min.js"></script>

Test

Thank you to BrowserStack for providing the infrastructure that allows to test in real browsers.

Test

License

MIT © antitim

Readme

Keywords

none

Package Sidebar

Install

npm i init-with-dom

Weekly Downloads

14

Version

1.2.5

License

MIT

Unpacked Size

11.3 kB

Total Files

17

Last publish

Collaborators

  • antitim