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

Project 1 Efficient Solution #7

Open
Prashantjha14 opened this issue Aug 12, 2023 · 3 comments
Open

Project 1 Efficient Solution #7

Prashantjha14 opened this issue Aug 12, 2023 · 3 comments

Comments

@Prashantjha14
Copy link

This is not any issue or something, but I want you to review my code of project 1. In this we don't have to edit any code in the JavaScript file.

I guess this is the fast way to contact you, so I am sending this in the Issue of GitHub.

const body = document.body;
const buttons = document.querySelectorAll(".button");

buttons.forEach((button) => {
  const color = button.getAttribute("id");
  button.addEventListener("click", (e) => {
    body.style.backgroundColor = color;
  });
});
@ghost
Copy link

ghost commented Aug 23, 2023

I have opened pull request for the same code before. Can I work on this issue.

@RiteshRay07
Copy link

RiteshRay07 commented Dec 22, 2023

Most effective ways

const buttons = document.querySelectorAll('.button');
const body = document.querySelector('body');

buttons.forEach(function (button) {
  console.log(button);
  button.addEventListener('click', function (e) {
    // console.log(e);
    // console.log(e.target);
  
    body.style.backgroundColor = e.target.id;
       });
});

@harsh-807
Copy link

why am i able to comment , even if the issue is closed ? is this a new update on G

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

3 participants