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

172
Views
getElementById that contains "abc" android onbackpressed

this is my onBackPressed:

@Override
    public void onBackPressed() {
        if (Config.EXIT_APP_BY_BACK_BUTTON_ALWAYS) {

            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl("javascript:(function(){"+
                    "l=document.getElementById('sdf_1422');"+
                    "e=document.createEvent('HTMLEvents');"+
                    "e.initEvent('click',true,true);"+
                    "l.dispatchEvent(e);"+
                    "})()");

}}

This works very well but the problem is that my page contains a lot of div's of sdf_1422, sdf_1423, sdf_1424, and so on. Can you help my to get all the sdf_, and click them.

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

0

You can get all the elements you are looking for with document.querySelectorAll("div[id^=sdf_]") This is looking for all divs with id starting with sdf_ . This function returns a nodelist.

You can iterate a nodelist and add an event to every node:

let list = document.querySelectorAll("div[id^=sdf_]");
list.forEach(element => { element.addEventListener('click', () => {}) })
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!