JSFiddle - React, Tailwind, and code Playground

by Serge Zahharenko

HTML

<div id="test" data-ga-action="test">test</div>

JavaScript

var CP = {
    qs: function (s) {
        return document.querySelectorAll(s)
    },
    onLoad: function (fn) {
        if (typeof fn === 'function') {
            document.addEventListener("DOMContentLoaded", fn);
        }
    },
    bindClick: function (el, fn) {
        if (typeof fn === 'function') {
            this.qs(el).forEach(function (node) {
                node.addEventListener('click', fn, false);
            })
        }
        return el;
    }
};

HTMLElement.prototype.val = function (value) {
    var type = this.tagName;
    var types = [ 'INPUT', 'SELECT', 'TEXTAREA' ];
    if (types.indexOf(type) >= 0) {
        if (value) {
            this.value = value;
            return this;
        } else {
            return this.value
        }
    } else {
        return 
    }
}

CP.onLoad(function(){
  var aa = CP.qs("*[data-ga-action]:not(input):not(select):not(textarea)");
  console.log(aa);
})

document.addEventListener('keydown', function (e) {
    alert("hallo" + e.keyCode);
});