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

262
Visualizações
Jquery - Hyperlink cannot be click

I have table, then table row can be clicked. But some cell, cannot be clicked if there is a hyperlinks. Because if i allow it, there will be 2 action. Action on tr click and action on hyperlink click.

so i decide to disable thats cell.

$("tbody").on("click", "tr td:last-child", function() { 
   return false;
});

But when i do this,, my hyperlink cannot be clicked.

This is my full script

$("tbody").on("click", "tr td:last-child", function() { 
    return false;
});
$("tbody").on("click", "tr td:nth-last-child(2)", function() { 
    return false;
});
$("tbody").on("click", "tr", function() {   
    console.log('tr click');
});

https://jsfiddle.net/1twzdm9c/18/

In my version, i cant click tr and hyperlink,, but in jsfiddle, im still can click tr but hyperlink cannot wont effect.

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

0

Just not bind the click in first place

$("tbody").find("tr td").not(":last,:nth-last-child(2)").on("click", function() {   
    console.log('tr click');
});

https://jsfiddle.net/27jygkqx/

about 4 years ago · Juan Pablo Isaza Relatório

0

add this attribute in non clickable td

<td data-click="false">....
 <td data-click="false">...

<script>  
    $("tbody").on("click", "tr td:not([data-click='false'])", function() {   
        console.log('tr click');
    });
</script>
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