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

README.md

Zelektor

####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
//Or
var $ = //Zelektor.min.js code goes here


// Then...

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

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

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

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

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

querySelectorAll
(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')) // => [div.foo]

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

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

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

Issues:

  • 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.