You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Haanji , in this you have used event listener to get the id of the color clicked. But we used the other way to solve this and found it somewhat interesting and better .
function clicked(z) {
const x = document
.querySelector('body')
.setAttribute('style', background-color:${z};);
}
const y = document.querySelectorAll('.button');
console.log(y);
y.forEach((button) => {
const x = button.getAttribute('id');
if (
(document.getElementById(x).onclick = () => {
if (true) {
console.log(x);
clicked(x);
}
})
);
});
The text was updated successfully, but these errors were encountered:
Haanji , in this you have used event listener to get the id of the color clicked. But we used the other way to solve this and found it somewhat interesting and better .
function clicked(z) {
const x = document
.querySelector('body')
.setAttribute('style',
background-color:${z};
);}
const y = document.querySelectorAll('.button');
console.log(y);
y.forEach((button) => {
const x = button.getAttribute('id');
if (
(document.getElementById(x).onclick = () => {
if (true) {
console.log(x);
clicked(x);
}
})
);
});
The text was updated successfully, but these errors were encountered: