https://github.com/eldoy/brsrkr
https://github.com/eldoy/brsrkr
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eldoy/brsrkr
- Owner: eldoy
- Created: 2019-10-23T05:50:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-10-23T11:14:02.000Z (almost 7 years ago)
- Last Synced: 2025-02-22T19:25:06.038Z (over 1 year ago)
- Language: JavaScript
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BRSRKR
Tiny Javascript HTML and DOM manipulation library, encapsulation style.
### Install
`npm i brsrkr`
### Usage
```javascript
// Get HTML
$('#app').html()
// Insert HTML
$('#app').html('
Before')
// Insert HTML before element
$('#app').html('
hello', 'before')
// Insert HTML after element
$('#app').html('
hello', 'after')
// Insert HTML at top of element
$('#app').html('
hello', 'top')
// Insert HTML at end of element
$('#app').html('
hello', 'end')
// Get text
$('#app').text()
// Insert text
$('#app').text('hello')
// Query DOM, uses callback
$('#app', el => el.textContent = 'hello')
// Function body applies to all matches
$('li', el => {
el.style.color = 'yellow'
el.textContent = 'hello'
// Can use brsrkr here too
$(el).html('Nice!')
// Query only inside el
$('span', el, span => {
span.style.display = 'none'
})
})
// Find all span inside '#el'
$('span', '#el', span => {
span.style.opacity = 1
})
// Get by index
$('li').get(0)
// Get number of matches
$('li').length
```
ISC licensed. Enjoy!