-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsscr.js
32 lines (24 loc) · 930 Bytes
/
sscr.js
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
31
const dom = document;
const device = window;
function add(tag, classes, id, sa, content) {
// create a new div element
const newDiv = document.createElement(tag);
// and give it some content
const newContent = document.createTextNode(content);
// add the text node to the newly created div
newDiv.appendChild(newContent);
// add the newly created element and its content into the DOM
const currentDiv = document.getElementById("div1");
document.body.insertBefore(newDiv, currentDiv);
// Set the classes and ID
currentDiv.setAttribute('class', classes);
currentDiv.setAttribute('id', id);
switch (tag) {
case 'a':
currentDiv.setAttribute('href', sa);
break;
case 'input':
currentDiv.setAttribute('type', sa)
}
return currentDiv;
}