Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

07_project Color Changer #49

Open
Bhaskar-N-Prasad opened this issue Mar 15, 2024 · 0 comments
Open

07_project Color Changer #49

Bhaskar-N-Prasad opened this issue Mar 15, 2024 · 0 comments

Comments

@Bhaskar-N-Prasad
Copy link

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);
}
})
);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant