https://github.com/lbenie/qselector
Aliases for querySelector & querySelectorAll
https://github.com/lbenie/qselector
browser dom javascript javascript-library node nodejs nodejs-modules query query-selector query-selector-all
Last synced: 3 months ago
JSON representation
Aliases for querySelector & querySelectorAll
- Host: GitHub
- URL: https://github.com/lbenie/qselector
- Owner: lbenie
- License: mit
- Created: 2018-04-10T00:17:05.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-10T05:51:08.000Z (over 1 year ago)
- Last Synced: 2025-02-01T06:47:46.939Z (4 months ago)
- Topics: browser, dom, javascript, javascript-library, node, nodejs, nodejs-modules, query, query-selector, query-selector-all
- Language: JavaScript
- Homepage: https://lbenie.netlify.com/
- Size: 2.32 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# qselector
[](https://travis-ci.org/lbenie/qselector)
[](https://stryker-mutator.github.io)
[](http://commitizen.github.io/cz-cli/)
[](https://github.com/lbenie/qselector)
[](https://snyk.io/test/github/lbenie/qselector?targetFile=package.json)
[](https://github.com/lbenie/qselector)
[](https://github.com/lbenie/qselector)
[](https://github.com/lbenie/qselector) [](https://greenkeeper.io/)qselector (query selector) is just a small package to create aliases for
`querySelector` and `querySelectorAll` to `$` and `$$` respectively.## API
The api is pretty simple. Each functions receive a DOMElement and returns either
the node or a list of node.**Example**
```html
s
t
u
```**$(el, selector)**
Returns the first match of `selector` on `el` and its children
```js
let node = $('div');
/* node value
s
t
u
*/node = $('span', '.test');
/* node value
s
*/
```**$$(el, selector)**
Returns the list of all matches of `selector` on `el` and its children
```js
let node = $$('div');
/* node value
[div.test, div.retest]
*/node = $$('.test', 'span');
/* node value
[span, span]
*/
```## Installation
```bash
$ yarn add qselector
```or
```bash
$ npm install qselector --save
```### Usage
```node
const qselector = require('qselector/dist/cjs')
``````ts
import qselector from 'qselector/dist/es2015')
```## License
(MIT)
Copyright (c) 2018 Lucien Bénié
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.