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

337
Views
Proper way of writing $(this).text().match(r) into vanilla JS?

I have the following function written in jQuery which I would like to convert to javascript but I couldn't find a proper way so far.

const word = document.getElementById("searchField").value;
        const r = new RegExp("(" + word + ")", "ig");
$(".list-item").each(function (i) {
            if ($(this).text().match(r)) {
                
            }
        });

I rewrote it this way:

const word = document.getElementById("searchField").value;
        const r = new RegExp("(" + word + ")", "ig");

        let pickComp = document.querySelectorAll('.list-item');
        Array.from(pickComp).forEach((i) => {
            if (//how can I rewrite the jQuery here?) {
                
            }
        })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const word = document.getElementById("searchField").value;
const r = new RegExp("(" + word + ")", "ig");

const pickComp = document.querySelectorAll('.list-item');

pickComp.forEach(item => {
      if (item.innerHTML.match(r)) {
        console.log("Match!!");
        }
      })
<p class="list-item">abc</p>
<p class="list-item">abc</p>
<p class="list-item">abc</p>
<p class="list-item">abc</p>
<input id="searchField" value="abc">

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!