Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. $(function() {
  2.  
  3. jQuery.fn.exists = function(){return this.length>0;}
  4.  
  5. // Dynamic Colspan
  6. if($('[colspan="auto"]').exists())
  7. {
  8. $.each($('[colspan="auto"]'), function( index, value ) {
  9. var table = $(this).closest('table'); // Get Table
  10. var siblings = $(this).closest('tr').find('th:visible, td:visible').not('[colspan="auto"]').length; // Count colspan siblings
  11. var numCols = table.find('tr').first().find('th:visible, td:visible').length; // Count visible columns
  12. $(this).attr('colspan', numCols.toString()-siblings); // Update colspan attribute
  13. });
  14. }
  15.  
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement