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

100
Visualizações
Function is executing inside button click automatically as default behavior

I have the code in below. There testFunction is executing automatically When the the button click is executing( default behavior of CMS I'm using. I want to override that behavior by skipping it in executing on button click). I want to skip executing the calling function named testFunction when the button click is executed. I tried below way without a success. Any input highly appreciated.


$(".classTest:not(selected)").find("button").on("click", function (){
      function testFunction(element,isSelected)
});

function testFunction(element, isSelected)(){ //code }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

One option might be to add a listener to an outer element (like the window), and on click, see if the target is one of those buttons - and if it is, call stopPropagation on the event to keep it from reaching the button.

window.addEventListener(
  'click',
  (e) => {
    if (e.target.matches('.classTest button')) {
      e.stopPropagation();
      // if you want something to happen when the button is clicked
      // put the code here
    }
  },
  true // add listener to capturing phase, not bubbling phase
);
about 4 years ago · Juan Pablo Isaza Relatório
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