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

418
Views
How can I use setAttribute() with class name

I have the following htmlhelper line:

@Html.ActionLink("Details", "LeadDetails", new {@class = "detailsLink", id = item.user_id, urlfrom = "ManageDeposits" })

on urlform I want to pass the current url using javascript.

I do not know what the specific ActionLink's id is so I decided to use class name detailsLink

However when I use: const det = document.getElementByName("detailsLink"); I cannot use the setAttribute() function.

Are there any alternatives to use setAttribute() by getting the element using class name instead of id?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try document.getElementsByClassName("detailsLink")[0] to get your element by class name, but be sure that your class name is unique (check that there is only one tag using class="detailsLink", otherwise you might need to change the number 0 by order)

about 4 years ago · Juan Pablo Isaza 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!