Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda