https://github.com/chadhietala/tquery
A tiny jQuery!
https://github.com/chadhietala/tquery
Last synced: 2 months ago
JSON representation
A tiny jQuery!
- Host: GitHub
- URL: https://github.com/chadhietala/tquery
- Owner: chadhietala
- Created: 2013-01-30T18:53:09.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-01-30T19:18:38.000Z (over 12 years ago)
- Last Synced: 2025-02-10T08:23:09.765Z (4 months ago)
- Language: JavaScript
- Size: 216 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Tiny jQuery
Build a small DOM manipulation library that exposes a jQuery-like API.
Unit tests have been provided. They are written with the QUnit testing
framework, and you can run them from the command line (see below), or by
visiting the `test/index.html` file from a browser. To complete this task,
get all the tests to pass!## Installing (optional)
You'll need [Node.js (http://nodejs.org)](http://nodejs.org) and [Grunt
(http://gruntjs.com)](http://gruntjs.com) if you want to lint your code and run
the tests from the command line.## API
Select DOM elements:
```javascript
var elems1 = $$(".selector #string > .here");
var elems2 = tQuery(".selector #string > .here");
```Array-like API:
```javascript
var spans = $$("span");spans.length; // Number, eg. 4
spans[0]; // DOM element
spans[3]; // DOM element
spans[4]; // undefined
```Optional `context` specified as a second argument:
```javascript
var elems = $$(".bob", document.getElementById("bocoup"));
```Iteration over selection:
```javascript
$$("div").forEach(function(elem, idx) {
console.log("Element #" + idx + " in this selection: ", elem);
});
```