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

253
Views
Find attribute value by searching inner text on a webpage

want to extract the value of value attribute in the code below by it's inner text using 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>

Here is what I want to extract from above html 123.

Any help will be appreciated. Thank You.

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

0

I did it myself, using:

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

from @Cybernetic in "How to get element by innerText":

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

This returned my desired value.

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!