Advertisement
Guest User

Untitled

a guest
Jan 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. <table>
  2. <tr>
  3. <td class="selector">
  4. <input type="checkbox" name="folders" value="67">
  5. </td>
  6. <td class="name">
  7. <a>Item 15</a>
  8. </td>
  9. <td class="creator">
  10. <span class="creator">Your Name</span>
  11. </td>
  12. <td class="last_modified">
  13. <time class="" datetime="2012-11-11T00:08:09Z">Nov-10 4:08 PM</time>
  14. </td>
  15. <td class="actions">
  16. <div class="actions-group">
  17. <a class="dropdown-toggle" data-toggle="dropdown">
  18. <i class="icon-gear">Settings</i>
  19. <i class="icon-caret"></i>
  20. </a>
  21. <ul class="dropdown-menu dropright">
  22. <li><a data-rename="true">Rename</a></li>
  23. <li><a data-archive="true">Delete</a></li>
  24. </ul>
  25. </div>
  26. </td>
  27. </tr>
  28. </table>
  29.  
  30. $("table").delegate("td", "click", function(e) {
  31. console.log(e);
  32. // e.delegateTarget === your table element
  33. // e.currentTarget === the td clicked
  34. // e.target === the actual element that you clicked
  35. });​
  36.  
  37. $("table").on('click', '.noclick', function (e) {
  38. e.stopPropagation();
  39. }).on("click", "td", function(e) {
  40. console.log(e);
  41. });
  42.  
  43. <input type="checkbox" class="noclick" name="folders" value="67">
  44.  
  45. $("table").on('click', 'td:not(.noclick)', function (e) {
  46. console.log(e);
  47. });
  48.  
  49. $("table").on('click', 'td', function (e) {
  50. if ($(this).hasClass('noclick')) { return; }
  51. console.log(e);
  52. });
  53.  
  54. <td class="selector noclick">
  55. <input type="checkbox" name="folders" value="67">
  56. </td>
  57.  
  58. $("table").on("click", "input", function(event){
  59. var clicked_checkbox = $(this);
  60. });
  61.  
  62. $("tr").click(function(event){
  63. if(!$(event.srcElement).is("a"))
  64. {
  65. var checkbox = $(this).find('input[type="checkbox"]');
  66. $(checkbox).prop("checked",!$(checkbox).prop("checked"));
  67. }
  68. });​
  69.  
  70. $("table").delegate("td", "click", function(e) {
  71. // Default stuff...
  72. console.log(e);
  73. });
  74.  
  75. $( 'a' ).click( function() {
  76. // Do something else...
  77. return false;
  78. });
  79.  
  80. $( 'input[type="checkbox"]' ).click( function() {
  81. // Do something else...
  82. return false;
  83. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement