Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

126
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda