Get started with simple-module CDN

MIT licensed

Library simple-module: create ES6 modules sans build tool.

Tags:
  • subclasses
  • extendable
  • jQuery

Stable version

Copied!

How to start using simple-module CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with simple-module CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/simple-module/3.0.3/simple-module.min.js"></script>
</head>
<body>
  <button id="add">Add</button>
  <button id="subtract">Subtract</button>
  <p id="counter">0</p>

  <script>
    const Counter = SimpleMDEditor.create(({ value = 0 }) => {
      let currentValue = value;

      const add = () => {
        currentValue += 1;
        counter.textContent = currentValue;
      };

      const subtract = () => {
        currentValue -= 1;
        counter.textContent = currentValue;
      };

      return { add, subtract };
    });

    const counter = document.getElementById('counter');
    const addButton = document.getElementById('add');
    const subtractButton = document.getElementById('subtract');

    Counter.initialize({
      target: counter,
      value: 0,
    });

    addButton.addEventListener('click', Counter.add);
    subtractButton.addEventListener('click', Counter.subtract);
  </script>
</body>
</html>
Copied!
Copied!

All versions