當我選擇已婚總數(shù)僅顯示為已婚,并且當我選擇未婚總數(shù)僅顯示為未婚,并且如果以上總數(shù)均未顯示時,我試圖計算列數(shù)。function filterText() { var rex = new RegExp($('#filterText').val().join('|')); if (rex == "/all/") { clearFilter() } else { $('.content').hide(); $('.content').filter(function() { return rex.test($(this).text()); }).show(); }}function clearFilter() { $('.filterText').val(''); $('.content').show();}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><select id='filterText' multiple="multiple" name="filterText[]" style='display:inline-block' onclick='filterText()'> <option disabled selected>Select</option> <option value='1'>Married</option> <option value='2'>Unmarried</option> <option value='all'>All</option></select><table id="table_format" border="1px"> <thead> <tr> <th>#</th> <th>First Name</th> <th>Number</th> <th>Married </th> </tr> </thead> <tbody> <tr class="content"> <td>1</td> <td>Mark</td> <td>25</td> <td>Married</td> </tr> <tr class="content"> <td>1</td> <td>Larry</td> <td>20</td> <td>Unmarried</td> </tr> <tr class="content"> <td>1</td> <td>Mark</td> <td>15</td> <td>Married</td> </tr> <tr class="content"> <td>2</td> <td>Jacob</td> <td>30</td> <td>Unmarried</td> </tr> <tr class="content"> <td>2</td> <td>Larry</td> <td>5</td> <td>Unmarried</td> </tr> <tr> <td>3</td> <td>Total</td> <td>800</td> <td>All</td> </tr> </tbody></table>我只想計算特定的選定值。如果有任何解決方案,請幫助我,并提前謝謝。
如何計算行總數(shù)onclick函數(shù)
猛跑小豬
2021-05-06 14:14:28