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

407
Views
How get the href of each class and store it inside a list (javascript)?

There is a list I have with 7 entries. On the picture below you can see the area which I marked purple: 6 entries. You see the area which I marked blue, all the 7 entries got the same <a class "FPmhX notranslate MBL3Z". My question is how can I get the href of each entry and store them all in a list/array? In this example, the href of first entry is /foo.96/.

If my question is not clear please tell me and I will try to describe it differently! :)

enter image description here

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

0

Create parent element of list in html and in your javascript write:

var links = document.querySelectorAll("a.FPmhX.notranslate.MBL3Z");
var list = document.querySelector("ul#linkList");///Your path to parent

for(var i=0;i<links.length;i++){
    list.innerHTML += "<li>" + links[i].href + "</li>";
}

Or if you want to get the pathname then use links[i].pathname instead of links[i].href.

Here's the snippet

var links = document.querySelectorAll("a.FPmhX.notranslate.MBL3Z");
var list = document.querySelector("ul#linkList");

for(var i=0;i<links.length;i++){
    list.innerHTML += "<li>" + links[i].href + "</li>";
}
<a href="https://www.w3schools.com/" class="FPmhX notranslate MBL3Z"></a>
<a href="https://developer.mozilla.org/en-US/" class="FPmhX notranslate MBL3Z"></a>
<a href="https://stackoverflow.com/questions" class="FPmhX notranslate MBL3Z"></a>
<a href="https://css-tricks.com/" class="FPmhX notranslate MBL3Z"></a>
<ul id="linkList">
  Links:
</ul>

Is it helpful? :)

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!