Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
can i change the style of my button using his name taken from array?

i have this array with my buttons being declared out of an array:

var buttons = [
  'button1',
  'button2',
  'button3',
  'button4',
  'button5',
  'button6',
];
let button = document.querySelector(".buttonstart");
let maintext = document.querySelector(".elementialText");
let button1 = document.querySelector(".button1");
let button2 = document.querySelector(".button2");
let button3 = document.querySelector(".button3");
let button4 = document.querySelector(".button4");
let buttoncontinue = document.querySelector(".buttoncontinue");
let button5 = document.querySelector('.button5');
let button6 = document.querySelector('.button6');

tried to change style of my buttons like this:

for (let i = 0; i < buttons.length; i++) {
    (buttons[i]).style.display = 'block';
  };

but it's not working. can i use .style.display using my array parameters?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Because you don't define the variable buttons as Node array. Try this:

let button = document.querySelector(".buttonstart");
let maintext = document.querySelector(".elementialText");
let button1 = document.querySelector(".button1");
let button2 = document.querySelector(".button2");
let button3 = document.querySelector(".button3");
let button4 = document.querySelector(".button4");
let buttoncontinue = document.querySelector(".buttoncontinue");
let button5 = document.querySelector('.button5');
let button6 = document.querySelector('.button6');

var buttons = [
  button1,
  button2,
  button3,
  button4,
  button5,
  button6,
];

for (let i = 0; i < buttons.length; i++) {
    buttons[i].style.display = 'block';
}
about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!