Skip to content

Instantly share code, notes, and snippets.

@maousan
Created March 29, 2016 16:44
Show Gist options
  • Select an option

  • Save maousan/223d1d019e24aa025f43a55bd2eacd2e to your computer and use it in GitHub Desktop.

Select an option

Save maousan/223d1d019e24aa025f43a55bd2eacd2e to your computer and use it in GitHub Desktop.
simple dom selector and iterator
var $dom = function (elem){
var _$ = document.querySelectorAll.bind(document);
function makeArray(arrLike) {
var arrLike = _$(elem);
return [].concat.apply([], arrLike);
}
Array.prototype.each = Array.prototype.forEach;
return makeArray(_$(elem));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment