• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

59
Views
Address attributes of HTML tags by CSS selector

I'm loading the name and id attributes of a <form> called contactForm to a javascript array like this:

const flds=[];
contactForm.querySelectorAll("input").
    forEach( value => { 
        flds.push([value.id, value.name])
    });
;
console.log(flds);

Can I do that directly without a loop? Something like:

const flds=contactForm.querySelectorAll("input [name,id]")
almost 3 years ago · Santiago Trujillo
1 answers
Answer question

0

I think the best you can do is a map function.

const flds = [...contactForm.querySelectorAll("input")].map(el => [el.id, el.name])
almost 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error