Update 'frontend.js'
This commit is contained in:
parent
eef7eb3df5
commit
2dc29a75a6
1 changed files with 10 additions and 1 deletions
11
frontend.js
11
frontend.js
|
@ -24,12 +24,21 @@ function createParagraph(elementID, text) {
|
|||
return elem
|
||||
}
|
||||
|
||||
function createButton(elementID, text) {
|
||||
function createButton(elementID, text, attributes = {}) {
|
||||
let elem = createElement("button", elementID);
|
||||
elem.innerText = `${text}`
|
||||
for (const [name, value] of Object.entries(attributes)) {
|
||||
elem.setAttribute(name, value);
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
function changeAttributes(elem, attributes = {}) {
|
||||
for (const [name, value] of Object.entries(attributes)) {
|
||||
elem.setAttribute(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
function createImage(elementID, src) {
|
||||
return createElement("img", elementID, { src: src });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue