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

158
Vistas
Javascript function waits until element shows

I want to write a function that will run when the "RUN TEST" button is pressed. This function is designed to hide the two buttons on the next page. Because the application reloads the entire page after pressing this button.

My problem is that when I press the "RUN TEST" button, the buttons I want to hide are not available yet.

$(document).ready(function () {
const button = findButtonByText("RUN TEST");

$(document).on("click", button, function() {
    hideUnnecessaryButtons();
});

function hideUnnecessaryButtons() {
    const buttonsToHide = ["DELETE", "ADD PERSON"];
    for(let j = 0; j < buttonsToHide.length; j++) {
        const button = findButtonByText(buttonsToHide[j]);              
        if(button !== undefined){
            button.style.display = "none";
        }
    }
}

function findButtonByText(text) {
    const buttons = document.querySelectorAll('button');
    for (let i = 0, l = buttons.length; i < l; i++) {
        if (buttons[i].innerText == text){
            return buttons[i];
        }
    }
}
});

How could I improve this feature to access loaded buttons this way?

about 4 years ago · Juan Pablo Isaza
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