3.2.5 • Published 2 years ago
jdom v3.2.5
JDOM.js
Installation
npm install --save jdom
Import
import {
domFactory, svgFactory,
on, once, off, dispatch,
style
} from 'jdom';
Compose DOM Example
example:
const {DIV, SCRIPT, SPAN} = domFactory;
const myDiv = DIV({
parent: document.body
id: 'myDiv',
style: {
color: 'red'
},
dataset: {
foo: 'bar'
},
children: [
'injecting script',
SCRIPT({src: 'http://some.url'}),
'done'
],
click: () => {
alert('now');
}
});
SPAN({parent: myDiv, children: ['SomeText!!!!']);
Compose SVG Example
example:
import {SVG, RECT, CIRCLE} from 'jdom';
SVG({
id: 'mySVG',
width: 200,
height: 200,
viewBox: '0 0 200 200',
children: [
RECT({
fill : 'red',
x:5,
y:5,
width: 190,
height: 190
}),
CIRCLE({
fill: 'yellow',
cx: 100,
cy:100,
r:80
})
],
parent: document.body
});
style (HTMLElement elem, object props)
update element style
example:
const a = document.getElementById('aDiv');
style(a, {
color: 'green',
backgroundColor: 'red'
})
QueryList(\$) (string/element/nodelist/array/function selector)
example:
const $a = $('#aDiv');
$a.on('click', () => {
if ($a.hasClass('foo')) {
$a.removeClass('foo').addClass('bar');
} else {
$a.removeClass('bar').addClass('foo');
}
});
$a.dispatch('click');
Querylist Event Methods
- on
- once
- off
- dispatch
Querylist Style Methods
- style
- hasClass
- addClass
- removeClass
Querylist Array Prototype Methods
- filter
- forEach
- map
- pop
- push
- shift
- slice
- some
- splice
- unshift
3.2.2
2 years ago
3.2.5
2 years ago
3.2.4
2 years ago
3.2.3
2 years ago
3.2.1
4 years ago
3.2.0
4 years ago
3.1.11
4 years ago
3.1.10
4 years ago
3.1.9
4 years ago
3.1.8
5 years ago
3.1.7
5 years ago
3.1.6
5 years ago
3.1.5
5 years ago
3.1.4
5 years ago
3.1.2
5 years ago
3.1.1
5 years ago
3.0.3
5 years ago
3.1.0
5 years ago
3.0.2
6 years ago
3.0.0
6 years ago
2.4.0
6 years ago
2.3.0
6 years ago
2.2.0
6 years ago
2.1.0
6 years ago
2.0.3
6 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.11
6 years ago
1.0.10
7 years ago
1.0.9
7 years ago
1.0.8
7 years ago
1.0.7
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago