JSFiddle - React, Tailwind, and code Playground

by someprimetime

HTML

<a id="js-handler">Click me</a>

JavaScript

var anchor = document.getElementById('js-handler');

var clickedIt = function(type) {
  alert('You clicked it with ' + type);
  return false;
}

function addListener(anchor) {
  var type;
  if (!anchor.addEventListener) {
    // IE
    type = 'and IE browser';
    anchor.attachEvent('click', clickedIt);
  } else {
    // Not IE
    type = 'not and IE browser';
    anchor.addEventListener('click', clickedIt, false);
  }
  clickedIt = clickedIt.call(undefined, type);
};

 
addListener(anchor);