nanoQuery.JS - efficient JQuery replacement in one line


SUBMITTED BY: Guest

DATE: Jan. 31, 2013, 12:02 p.m.

FORMAT: JavaScript

SIZE: 480 Bytes

HITS: 3661

  1. /*
  2. * nanoQuery function (can replace jQuery in 90% cases)
  3. * Syntax:
  4. * _(selector) - select and return the first matching element
  5. * _(selector, callback) - perform a callback on all selected elements
  6. * _(selector, event, handler) - add event handler to all selected elements
  7. */
  8. window._=window.nanoQuery=function(s,c,x){var r=document.querySelectorAll(s);return r.length?(c?[].forEach.call(r,x?function(e){e.addEventListener(c,x,!!0)}:c):r[0]):null}

comments powered by Disqus