Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hikari-no-yume/jinsert
jInsert is my tiny DOM manipulation library. Some people like to j*Query* the DOM. I prefer to j*Insert* into it.
https://github.com/hikari-no-yume/jinsert
Last synced: 17 days ago
JSON representation
jInsert is my tiny DOM manipulation library. Some people like to j*Query* the DOM. I prefer to j*Insert* into it.
- Host: GitHub
- URL: https://github.com/hikari-no-yume/jinsert
- Owner: hikari-no-yume
- Created: 2013-12-26T00:28:15.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-11T13:23:55.000Z (almost 9 years ago)
- Last Synced: 2024-10-31T05:08:13.765Z (2 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jInsert
=======jInsert is my tiny DOM manipulation library. Some people like to j*Query* the DOM. I prefer to j*Insert* into it.
License
-------MIT license, see header comment of jInsert.js.
API
---* `$`(*tagName*[, *props*][, *children*])
Creates an element of type `tagName`.
If given, `props` is iterated over, copying each property from props to the new element. If there is a `style` property, it is not copied directly, but rather its properties are copied to the new element's `.style` object.
If given, `children` is iterated over, with each item being appended (with `appendChild`) to the new element. If the item is a string, it is converted to a DOM text node before being appended.
Returns the new element.Thus you can build DOM elements with a leaner syntax closer to HTML. For example, this jInsert code produces a form:
```JavaScript
document.body.appendChild($('form', {action: '/submit', method: 'POST'}, [
$('input', {type: 'text', name: 'username'}),
$('br'),
$('input', {type: 'password', name: 'password'}),
$('br'),
$('input', {type: 'submit'})
]));
```And is equivalent to this HTML:
```HTML
```