Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda