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

182
Visualizações
Detect click outside a <td> using jQuery

I have a td like below.

<td class="volunteer" id="422" data-select2-id="select2-data-422">
    <select multiple="" data-select2-id="select2-data-1-dpng" tabindex="-1" class="select2-hidden-accessible" aria-hidden="true">
        //more code here
    </select>
    <span class="select2 select2-container select2-container--default select2-container--below select2-container--focus" dir="ltr" data-select2-id="select2-data-2-ooba" style="width: 16px;">
      //more code here    
    </span>
</td>

I would like to detect click outside of this td. I used below jQuery code.

$(document).click(function (e) {
  alert('hello');
  $('.volunteer *').unbind('click');
});

But it is not working.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

First of all, I'd add the listener to document.body then I'd check if the event target is or is contained in volunteer

$(document.body).click(function (e) {
  alert('hello');
  if (!e.target.closest('.volunteer')) {
    $('td.volunteer *').unbind('click');
  }
});
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