SHARE
TWEET

Untitled

a guest Sep 12th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const myButton = document.createElement('button');
  2. var buttonText = 0;
  3. myButton.innerHTML = buttonText;
  4. myButton.id = "button";
  5. myButton.style.width = "96px";
  6. myButton.style.height = "48px";
  7. myButton.style.fontSize = "24px";
  8.  
  9. const body = document.querySelector('body');
  10. body.appendChild(myButton);
  11.  
  12.  
  13. document.addEventListener('click', function(event){
  14.    // If the clicked element doesn't have the right selector, bail
  15.     if (!event.target.matches('#button')) return;
  16.  
  17.     // Don't follow the link
  18.     event.preventDefault();
  19.     buttonText++;
  20.     myButton.innerHTML = buttonText;
  21. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top