コードを実行するとチェックボックスフィルタが付いたテーブルがありますが、フィルタを実行するときにチェックボックスをオンにしてもカウントされません.html:フィルタを使用しているときにコード内の行がカウントされないのはなぜですか?
<table class="checkcontainer">
<tr>
<td>
<input type='checkbox' name='filter' id="One" checked="" value="One" onchange="chct()"/> One
</td>
<td>
<input type='checkbox' name='filter' id="Two" checked="" value="Two" /> Two
</td>
<td>
<input type='checkbox' name='filter' id="Three" checked="" value="Three" /> Three
</td>
</tr>
</table>
<table class="datatbl" border=1 >
<tr>
<th>No.</th>
<th>Content</th>
<th>Type</th>
</tr>
<tbody id="aaa">
<tr data-rowtype="One">
<td>1</td>
<td>this is first row</td>
<td>One</td>
</tr>
<tr data-rowtype="Two">
<td>2</td>
<td>this is second row</td>
<td>Two</td>
</tr>
<tr data-rowtype="Three">
<td>3</td>
<td>this is third row</td>
<td>Three</td>
</tr>
<tr data-rowtype="One">
<td>4</td>
<td>this is fourth row</td>
<td>One</td>
</tr>
<tr data-rowtype="Two">
<td>5</td>
<td>this is fifth row</td>
<td>Two</td>
</tr>
<tr data-rowtype="Three">
<td>6</td>
<td>this is sixth row</td>
<td>Three</td>
</tr>
</tbody>
JS:
window.console.clear();
$('.checkcontainer').on('change', 'input[type="checkbox"]', function() {
var cbs = $('.checkcontainer').find('input[type="checkbox"]');
var all_checked_types = [];
cbs.each(function() {
var mycheckbox = $(this);
$('.datatbl tr').filter(function() {
return $(this).data('rowtype') == mycheckbox.val();
}).toggle(mycheckbox[0].checked);
});
});
$("#total").text($("#aaa tr").length);
function chct() {
$("#total").text($("#aaa tr").length);
}
私は、チェックボックスをチェックしますが、フィルタのチェックボックスを使用しているとき、私は、テーブル内の行をカウントすることができますどのように
を実行していないテーブルの行をカウントする機能はいつですか?
は
ありがとうございました(これは、そのテーブルに表示TRをカウント)BRO ^^ – Xerek
これはあなたの問題をソルバー場合は、あなたは答えを受け入れてください(上/下の投票ボタンの下の白いチェックマーク)この質問が回答されたことを示す。ありがとう。 –