Lightweight alternative to jQuery selectors & basic utilities
- ⬇️ Download
- Include the library in your page
<script src="path/to/kew.min.js"></script>
Execute a callback when the DOM is ready.
Example
$kew().ready(function(){
// code to be executed after document has loaded
});
Select elements based on a CSS selector.
Example
$kew('div');
$kew('.foo div');
$kew('#foo.bar');
Execute a callback for each element.
Example
$kew('#foo').each(function(el) {
console.log(el.innerHTML);
});
Adds an attribute to all selected elements.
Example
$kew('#foo').attr('data-custom', 'myValue');
// result: <div id="foo" data-custom="myValue"></div>
Add a class to each selected elements.
Example
$kew('#foo').addClass('bar');
Remove a class from each selected elements.
Example
$kew('#foo').removeClass('bar');
Removes selected elements from the document.
$kew('#foo').removeElements();
If you would like to contribute and you will make modifications to kew.js
, then you will need to make sure you have NodeJS to install. You can get it here.
C:\> cd path/to/project/kewjs
C:\path\to\project\kewjs> grunt
Running "uglify:build" (uglify) task
Done, without errors.
C:\path\to\project\kewjs>