<table>
<tbody attributes="size">
<tr>
<th>Dans ce tbody, certaines rangées sont "disabled", d'autres non. Donc il doit être affiché, mais les rangées "disabled" doivent être masquées.</th>
</tr>
<tr class="headings">
<th>Name</th>
<th>Selector</th>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">A</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number" disabled="disabled">
</td>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">B</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number">
</td>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">C</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number">
</td>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">D</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number" disabled="disabled">
</td>
</tr>
</tbody>
<tbody attributes="size">
<tr>
<th>Toutes les rangées sont "disabled", le tbody doit donc être entièrement masqué.</th>
</tr>
<tr class="headings">
<th>Name</th>
<th>Selector</th>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">A</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number" disabled="disabled">
</td>
</tr>
<tr>
<td rowspan="1" class="vertical-attribute">B</td>
<td rowspan="1" class="horizontal-attribute">
<input class="product-quantity" type="number"...
JavaScript
/* cache la rangée lorsqu'input disabled */
$('input.product-quantity:disabled').closest('tr').hide();
/* variable pour le input */
var e = $('input').not('[disabled="disabled"]');
/* variable pour l'attribut taille */
var montbody = $('tbody[attributes="size"]');
/* si le tbody a plus de 0 input non-désactivés, le tbody est affiché, sinon il ne l'est pas
*/
$("table tbody").each(function() {
if ($(this).find(" tr:visible").length <= 2) {
$(this).css('visibility', 'hidden');
}
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.