-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (30 loc) · 883 Bytes
/
script.js
File metadata and controls
37 lines (30 loc) · 883 Bytes
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
36
37
const Button = (text, callback) => {
const body = document.querySelector("div.group-btn")
const button = document.createElement("button")
button.textContent = text
button.classList.add("btn-style")
button.setAttribute("role", "button")
callback(button)
body.insertAdjacentElement("beforeend", button)
return button
}
Button("Primary", (button) => {
button.style.cssText = `
background-color: #007bff;
border-color: #007bff;
`
button.setAttribute("aria-describedby", "primary alert button")
button.addEventListener("click",() => {
alert("Primary button click!")
})
})
Button("Danger", (button) => {
button.style.cssText = `
background-color: #c82333;
border-color: #bd2130;
`
button.setAttribute("aria-describedby", "primary danger button")
button.addEventListener("click",() => {
alert("Danger button click!")
})
})