Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!