我有一个Html表,其中已为表的一列添加了列过滤器。
选择下拉菜单后,如何获得所选值?
你能建议我有什么想法吗?
HTML:
<table id="maintable" class="tablesorter custom-popup">
<thead>
<tr>
<th class="filter-false">S.no</th>
<th class="filter-false">name</th>
<th class="filter-select" data-placeholder="Select All">Department</th>
<th class="filter-false">Age</th>
<th class="filter-false">Section</th>
</tr>
</thead>
<tbody>
//table body
</table>
JS
$(function() {
/*** custom css only button popup ***/
$(".custom-popup").tablesorter({
headers: {2: {sorter: 'name'} },
sortList: [[1,0],[2,0],[5,0],[3,0]],
theme: 'blue',
widgets: ['zebra', 'columnSelector', 'stickyHeaders','sort2Hash', 'filter'],
widgetOptions :
filter_cssFilter: '', // or []
// if true, a filter will be added to the top of each table column;
// disabled by using -> headers: { 1: { filter: false } } OR add class="filter-false"
// if you set this to false, make sure you perform a search using the second method below
filter_columnFilters: true
每个过滤器都有一个.tablesorter-filter
类。
此外,它具有一个data-column
属性,其值是该列的索引(0是第一列的值)。
所以:
$('.my-custom-button').click(function(){
var filterValue = $('.tablesorter-filter[data-column=2]').val();
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句