Guest User

Untitled

a guest
Jan 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <table class="table-list">
  2. <tbody>
  3. <tr>
  4. <td>...</td>
  5. <td><a href="/link">Link</a></td>
  6. </tr>
  7. </tbody>
  8. </table>
  9.  
  10. <script>
  11. $(function() {
  12. $('.table-list tr').live('click', function() {
  13. $('a:last', this).click();
  14. });
  15. });
  16. </script>
  17.  
  18. <script>
  19. $(function() {
  20. $('.table-list tr').live('click', function() {
  21. $(this).off('click');
  22. $('a:last', this).click();
  23. $(this).on('click');
  24. });
  25. });
  26. </script>
  27.  
  28. $(function() {
  29. $('.table-list').on('click', 'tr', function(){
  30. $(this).find('a:last').trigger('click');
  31. });
  32.  
  33. $('.table-list').on('click','a',function(e){
  34. e.stopImmediatePropagation();
  35. });
  36. });
  37.  
  38. <table class="table-list">
  39. <tbody>
  40. <tr style='border: 1px solid black;'>
  41. <td>.1.</td><td>.2.</td><td>.3.</td><td>.4.</td><td>.5.</td>
  42. <td class='link'><a href="/link" target="_blank">Link</a></td>
  43. </tr>
  44. <tr style='border: 1px solid black;'>
  45. <td>.1.</td><td>.2.</td><td>.3.</td><td>.4.</td><td>.5.</td>
  46. <td class='link'><a href="/link">Link2</a></td>
  47. </tr>
  48. </tbody>
  49. </table>​
  50.  
  51. $('.table-list td').each(function(){
  52. if ($(this).find('a').length === 0){
  53. $(this).on('click', function(){
  54. var link = $(this).siblings('.link').find('a');
  55. if (link.attr('target') === '_blank'){
  56. window.open(link.attr('href'));
  57. }
  58. else {
  59. window.location = link.attr('href')
  60. }
  61. });
  62. }
  63. });
Add Comment
Please, Sign In to add comment