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

245
Views
Encuentre el valor del atributo buscando texto interno en una página web

desea extraer el valor del atributo de valor en el código a continuación por su texto interno usando javascript.

 <label for="played-123"> <input id="played-123" name="players[]" type="checkbox" **value="123"**> <img class="team" src="teams/abc.png" alt="abc"> Abc Xyz</label>

Esto es lo que quiero extraer del html 123 anterior.

Cualquier ayuda será apreciada. Gracias.

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

0

Lo hice yo mismo, usando:

 function get_elements_by_inner(word) { res = [] elems = [...document.getElementsByTagName('label')]; elems.forEach((elem) => { if(elem.outerHTML.includes(word)) { res.push(elem) } }) return(res) }

de @Cybernetic en " Cómo obtener un elemento por texto interno ":

 get_elements_by_inner("Abc Xyz")[0].firstElementChild.attributes.value.nodeValue;

Esto devolvió mi valor deseado.

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!