Update 'frontend.js'

This commit is contained in:
nodemixaholic 2024-03-31 19:51:40 +00:00
parent eef7eb3df5
commit 2dc29a75a6

View file

@ -24,12 +24,21 @@ function createParagraph(elementID, text) {
return elem return elem
} }
function createButton(elementID, text) { function createButton(elementID, text, attributes = {}) {
let elem = createElement("button", elementID); let elem = createElement("button", elementID);
elem.innerText = `${text}` elem.innerText = `${text}`
for (const [name, value] of Object.entries(attributes)) {
elem.setAttribute(name, value);
}
return elem; return elem;
} }
function changeAttributes(elem, attributes = {}) {
for (const [name, value] of Object.entries(attributes)) {
elem.setAttribute(name, value);
}
}
function createImage(elementID, src) { function createImage(elementID, src) {
return createElement("img", elementID, { src: src }); return createElement("img", elementID, { src: src });
} }