Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
nanoQuery.JS - efficient JQuery replacement in one line
SUBMITTED BY:
Guest
DATE:
Jan. 31, 2013, 12:02 p.m.
FORMAT:
JavaScript
SIZE:
480 Bytes
Raw
Download
Tweet
HITS:
3661
Go to comments
Report
/*
* nanoQuery function (can replace jQuery in 90% cases)
* Syntax:
* _(selector) - select and return the first matching element
* _(selector, callback) - perform a callback on all selected elements
* _(selector, event, handler) - add event handler to all selected elements
*/
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
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus