We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f1f16f commit c0ca2aeCopy full SHA for c0ca2ae
project1-colors/src/Button.js
@@ -2,4 +2,11 @@ export default function Button({ $target, onClick }) {
2
const $button = document.createElement("button");
3
$target.append($button);
4
$button.textContent = "Click Me!";
5
+
6
+ $button.addEventListener("click", (e) => {
7
+ const generateRandomColorCode = () => {
8
+ return Math.floor(Math.random() * 16777215).toString(16);
9
+ };
10
+ onClick(generateRandomColorCode());
11
+ });
12
}
project1-colors/src/main.js
@@ -4,4 +4,7 @@ const $app = document.querySelector("#app");
new Button({
$target: $app,
+ onClick: (colorCode) => {
+ $app.style.backgroundColor = `#${colorCode}`;
+ },
});
0 commit comments