Dynamic Colspan / Colspan All Columns On Bootstrap Sample
Có thể bạn quan tâm
Skip to content All gists Back to GitHub Sign in Sign up Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }}
Raw index.html This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment You can’t perform that action at this time.
Instantly share code, notes, and snippets.
afbora/dynamic_colspan.js Last active February 12, 2019 10:24 Show Gist options- Download ZIP
- Star ( ) You must be signed in to star a gist
- Fork ( ) You must be signed in to fork a gist
- Embed Clone this repository at <script src="https://gist.github.com/afbora/6c98337a3455d45b6ae4e620d5cfbcf2.js"></script>
- Save afbora/6c98337a3455d45b6ae4e620d5cfbcf2 to your computer and use it in GitHub Desktop.
$(function() { |
jQuery.fn.exists = function(){return this.length>0;} |
// Dynamic Colspan |
if($('[colspan="auto"]').exists()) |
{ |
$.each($('[colspan="auto"]'), function( index, value ) { |
var table = $(this).closest('table'); // Get Table |
var siblings = $(this).closest('tr').find('th:visible, td:visible').not('[colspan="auto"]').length; // Count colspan siblings |
var numCols = table.find('tr').first().find('th:visible, td:visible').length; // Count visible columns |
$(this).attr('colspan', numCols.toString()-siblings); // Update colspan attribute |
}); |
} |
}); |
<table class="table"> |
<thead> |
<tr> |
<th>#</th> |
<th>First Name</th> |
<th>Last Name</th> |
<th>Username</th> |
<th class="hidden-xs">Birthdate</th> |
</tr> |
</thead> |
<tbody> |
<tr> |
<td colspan="auto">Employers</th> |
</tr> |
<tr> |
<th scope="row">1</th> |
<td>Mark</td> |
<td>Otto</td> |
<td>@mdo</td> |
<td class="hidden-xs">1980</td> |
</tr> |
<tr> |
<th scope="row">2</th> |
<td>Jacob</td> |
<td>Thornton</td> |
<td>@fat</td> |
<td class="hidden-xs">1975</td> |
</tr> |
<tr> |
<th scope="row">3</th> |
<td>Larry</td> |
<td>the Bird</td> |
<td>@twitter</td> |
<td class="hidden-xs">1977</td> |
</tr> |
</tbody> |
</table> |
Từ khóa » Html Colspan Dynamic
-
Dynamic Colspan - Php - Stack Overflow
-
ColSpan - Dynamic HTML: The Definitive Reference [Book] - O'Reilly
-
How To Deal With Table Colspans That May Change At Runtime - SitePoint
-
How Can I Create Col Span Or Row Span On Dynamic Table.
-
Colspan On Dynamically Loaded Content — DataTables Forums
-
SO Qn: Create A Table With Colspan And An Dynamic ... - JSFiddle
-
Dynamic Colspan In Angular Code Example
-
Dynamic Colspans With Angular - CodePen
-
How To Set Colspan Value Dynamically In QWeb? - Odoo
-
How To Dynamically Add Colspan To Different
In Table (Angular 4) How To Dynamically Add Colspan To Different Th In Table Angular 4
Js Method For Dynamically Modifying The Column Span Of Colspan ...
Building Dynamic Tables Cells And Specifying Colspan - Javascript
HTML DOM TableData ColSpan Property - W3Schools
Copyright © 2022 | Thiết Kế Truyền Hình Cáp Sông Thu