Skip to content
tiny selector engine for javascript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


####Recent updates:

  • 31 March 2014 — document.getElementsByClassName polyfill redone and tested in IE8 (stable); no polyfill for IE5, 6, or 7
  • 25 March 2014 — document.getElementsByClassName polyfill for IE<9 (uses querySelectorAll for IE8, and loops through all elements for IE<8)

A simple JavaScript selector engine (weighs about 1kb minified).

Returns an array of one or more DOM elements.

For limited use in production environments due to lack of browser testing.

Use it:

Assign the module to whatever variable you want:

var Zelekt = //Zelektor.min.js code goes here
var $ = //Zelektor.min.js code goes here

// Then...

var divs = Zelekt('div');
var divs = $('div');

$('#foo') // => [div#foo]

$('.foo') // => [,]

$('@foo') // => [div, div]

$('div') // => [div, div, div, div]

(put an asterisk before whatever CSS2/3-style selector you'd like to use)
$('*div > input') // => [input, input]

Also accepts a DOMElement for cases in which recursive selection is necessary:
$(document.getElementById('foo')) // => [div#foo]

Set the context of the selector if you want:
$('.foo', $('#bar')) // => []

You can also create an element and return it as your selection:

var newElement = $( '<div id="foo" class="bar"></div>', 'appendTo', $('.baz') ); // => []

var html = $('.baz')[0].innerHTML;        // => '<div id="foo" class="bar"></div>'


  • Limited browser testing
  • Only supports CSS-style selectors through querySelectorAll

The MIT License - (c) 2014, Joshua Beam

You can’t perform that action at this time.