I've created a personal API for creating elements for an HTML page. I would like feedback on efficiency, particularly in creating buttons and labels. Any and all feedback is appreciated and considered
tag.js
/*
* Shortcuts for creatings different tags
*/
function createLabel(text) {
let label_tag = document.createElement('label');
let label_tag_text = document.createTextNode(text);
tabel_tag.appendChild(label_tag_text);
return label_tag;
}
function createButton(type) {
/* need to manually add .onclick when creating button */
let button_tag = document.createElement('button');
button_tag.type = type;
return button_tag;
}
function createInput(type, id) {
let input_tag = document.createElement('input');
input_tag.type = type;
input_tag.id = id;
return input_tag;
}
function createDiv(id) {
let div_tag = document.createElement('div');
div_tag.id = id;
return div_tag;
}
function createTag(tag) {
/*
* Used for creating basic tags (<p>, <br>, <hr>, etc)
* Any tag that doesn't often use an ID, TYPE, NAME, CLASS, etc
*/
return document.createElement(tag);
}