JSFiddle - React, Tailwind, and code Playground
by rmurphey
HTML
<div class="foo">foo</div>
JavaScript
var count = function (start, end) {
var timeout;
function doIt () {
console.log(start++);
if (start <= end) {
timeout = setTimeout(doIt, 1000);
}
};
doIt();
return {
cancel : function () {
if (timeout) {
clearTimeout(timeout);
}
}
};
};
// count(1, 100);
var fn = function () {
var list = [];
function recurse () {
var args = [].slice.call(arguments);
if (!args.length) {
console.log( list.join(' ') );
} else {
list = list.concat(args);
return recurse;
}
};
return recurse.apply(null, arguments);
};
// fn('hello')('world')('goodbye')();
var gebc = function (className) {
var found = [];
var regex = new RegExp(className);
function find (el) {
var children = [].slice.call(el.childNodes);
var i, child, _c;
var length = children.length;
for (i = 0; i < length; i++) {
child = children[i];
_c = child.className && child.className.split(' ');
if ( _c && _c.length && _c.indexOf(className) > -1 ) {
found.push(child);
}
find(child);
}
}
find(document);
return found;
};
// console.log( gebc('foo') );