简体   繁体   English

如何显示所选表格行?

[英]How to show selected table row?

I am trying to show selected table rows in a table, I have created a fiddle here: 我试图显示表中选定的表行,我在这里创建了一个小提琴:

http://jsfiddle.net/tonymaloney1971/1wsvayuL/ http://jsfiddle.net/tonymaloney1971/1wsvayuL/

I have tried various methods, but cannot sem to get it to hide the selected rows. 我尝试了各种方法,但是无法将其隐藏起来以隐藏所选行。 I am thinking it is the visible property on ? 我认为这是可见的财产?

$('#showSelected').click(function (event) {
});

Any help? 有什么帮助吗?

Thanks 谢谢

here you go: DEMO 在这里,你去: 演示

$('#showSelected').click(function (event) {
    $('input[type=checkbox]').each(function(){
        if(!$(this).prop('checked')){
            $(this).closest('tr').hide();
        }
    });
});

$('#showAll').click(function (event) {
    $('input[type=checkbox]').closest('tr').show();
});

try 尝试

$('#showSelected').click(function (event) {
   var tr= $("[type=checkbox]:checked").map(function(){       
    return  $(this).closest("tr").text();
    }).get();
});

OR simply you can use 或者您可以简单地使用

 $("[type=checkbox]:checked").show();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM