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

170
Views
getElementById que contiene "abc" android onbackpressed

este es mi 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);"+ "})()"); }}

Esto funciona muy bien, pero el problema es que mi página contiene muchos div de sdf_1422, sdf_1423, sdf_1424, etc. ¿Puede ayudarme a obtener todos los sdf_ y hacer clic en ellos?

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

0

Puede obtener todos los elementos que está buscando con document.querySelectorAll("div[id^=sdf_]") Esto busca todos los divs con id que comienzan con sdf_ . Esta función devuelve una lista de nodos.

Puede iterar una lista de nodos y agregar un evento a cada nodo:

 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!