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

125
Views
Javascript Function - Return Response

I am new to javascript and trying to run a javascript function and return a response for this website below. I am trying to use 'document.querySelectorAll' to return a response for all the job titles and the URL for each job posting. How do I return a response for these elements?

Website: https://mckesson.wd3.myworkdayjobs.com/External_Careers

Here is my latest attempt:

function ExecuteScript() {
 let nameList = [];
 let response = '';

 document.querySelectorAll('a[data-automation-id="jobTitle"]').forEach((element, i) => {
  nameList.push(element.innerHTML);

 document.querySelectorAll('a[data-automation-id="jobTitle"]').forEach((element, i) => {
  response += nameList[i] + '\\t' + element.getAttribute('hef') + '\\n';
 });

 return response;
}

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

0

There are several problems with the example code:

  1. Syntax error: Two querySelectorAll are not nested correctly.

  2. Misspellings: hef should be href, and it's not enough to store only relative addresses; you need to add domain names in front of them.

  3. Because both capture elements of the same class, the two loops can be merged.

Can refer to the following code:

function ExecuteScript() {
  let response = '';
  document.querySelectorAll('a[data-automation-id="jobTitle"]').forEach((element, i) => {
    response += element.innerHTML + '\\t' + location.host + element.getAttribute('href') + '\\n';
  });
  return response;
}
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!