From 2dc29a75a64c8fcdcceb864e84e72e76db8cacb8 Mon Sep 17 00:00:00 2001 From: nodemixaholic Date: Sun, 31 Mar 2024 19:51:40 +0000 Subject: [PATCH] Update 'frontend.js' --- frontend.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend.js b/frontend.js index 0c8189d..9035973 100644 --- a/frontend.js +++ b/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 }); }