-
Notifications
You must be signed in to change notification settings - Fork 0
/
domModules.js
35 lines (31 loc) · 1.15 KB
/
domModules.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
32
33
34
35
function createDiv (divId, divClass, parentId) {
var createDiv = document.createElement("div");
createDiv.id = divId;
createDiv.className = divClass;
document.getElementById(parentId).appendChild(createDiv);
}
function createLabel (forValue, labelInnerHtml, parentId) {
var label = document.createElement("label");
label.setAttribute("for", forValue);
label.innerHTML = labelInnerHtml;
document.getElementById(parentId).appendChild(label);
}
function createInput (inputId, inputClass, inputPlaceholder, parentId) {
var input = document.createElement("input");
input.id = inputId;
input.className = inputClass;
input.placeholder = inputPlaceholder;
document.getElementById(parentId).appendChild(input);
}
function createButton (buttonId, buttonClass, buttonType, buttonInnerHTML, buttonClick, parentId) {
var button = document.createElement("button");
button.id = buttonId;
button.className = buttonClass;
button.type = buttonType;
button.innerHTML = buttonInnerHTML;
button.onclick = buttonClick;
document.getElementById(parentId).appendChild(button);
}
function capitalizeFirstLetter (string) {
return string[0].toUpperCase() + string.slice(1);
}