-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (21 loc) · 725 Bytes
/
script.js
File metadata and controls
30 lines (21 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// get the script
const createElement = require(`../`);
let elt = null;
// some examples
elt = createElement(); // <div></div>
elt = createElement('span#my-id'); // <span id="my-id"></span>
elt = createElement('span.my-class'); // <span class="my-class"></span>
elt = createElement('span#my-id.my-class'); // <span id="my-id" class="my-class"></span>
elt = createElement('a[href=#].link'); // <a class="link" href="#"></a>
elt = createElement('div',
'paragraphs',
createElement('p', 'paragraph 1'),
createElement('p', 'paragraph 2')
);
// <div>
// paragraphs
// <p>paragraph 1</p>
// <p>paragraph 2</p>
// </div>
// add the generated element to the DOM
document.querySelector('body').appendChild(elt);