Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在每个TR中隐藏n个TD_Jquery - Fatal编程技术网

Jquery 如何在每个TR中隐藏n个TD

Jquery 如何在每个TR中隐藏n个TD,jquery,Jquery,现在,我试图在每个TR中显示默认的4行数据,即使它少于TR中的4行。第二件事是要隐藏每个TR中的其余行。 最后,当我点击show按钮时,所有行都需要显示 提前感谢您在tr中创建了tr,这是错误的 您的代码应该如下所示: HTML: <table id="effect"> <tr id="complete"> <td>0000000</td> <td>1111111</td>

现在,我试图在每个TR中显示默认的4行数据,即使它少于TR中的4行。第二件事是要隐藏每个TR中的其余行。 最后,当我点击show按钮时,所有行都需要显示


提前感谢您在
tr
中创建了
tr
,这是
错误的

您的代码应该如下所示:

HTML:

<table id="effect">
    <tr id="complete">
        <td>0000000</td>
        <td>1111111</td>
        <td>2222222</td>
        <td>0000000</td>
        <td>1111111</td>
        <td>2222222</td>
    </tr>
    <tr id="reject">
        <td>aaaaaaa</td>
        <td>bbbbbbb</td>
        <td>ccccccc</td>
    </tr>

</table>

<button id="button">show</button>
$(function(){

    $(" #complete td").each(function(index){
        if(index>3)
            $(this).hide();
    });
    $(" #reject td").each(function(index){
        if(index>3)
            $(this).hide();
    });

    $( "#button" ).click(function() {
        if($(this).text()=='show more') // whatever your initial value  
             $(this).text('show less');
        else
             $(this).val('show more');
        $(" #complete td").each(function(index){
            if(index>3)
                $(this).toggle();
        });
        $(" #reject td").each(function(index){
            if(index>3)
                $(this).toggle();
        });
    });  
});

您在
tr
中创建了
tr
,这是
错误的

您的代码应该如下所示:

HTML:

<table id="effect">
    <tr id="complete">
        <td>0000000</td>
        <td>1111111</td>
        <td>2222222</td>
        <td>0000000</td>
        <td>1111111</td>
        <td>2222222</td>
    </tr>
    <tr id="reject">
        <td>aaaaaaa</td>
        <td>bbbbbbb</td>
        <td>ccccccc</td>
    </tr>

</table>

<button id="button">show</button>
$(function(){

    $(" #complete td").each(function(index){
        if(index>3)
            $(this).hide();
    });
    $(" #reject td").each(function(index){
        if(index>3)
            $(this).hide();
    });

    $( "#button" ).click(function() {
        if($(this).text()=='show more') // whatever your initial value  
             $(this).text('show less');
        else
             $(this).val('show more');
        $(" #complete td").each(function(index){
            if(index>3)
                $(this).toggle();
        });
        $(" #reject td").each(function(index){
            if(index>3)
                $(this).toggle();
        });
    });  
});

罗汉·库马尔代码的较短版本:


Rohan Kumar代码的较短版本:


代码引用:这是错误的。您在java中使用了tr:iterator,所以任何其他方法都可以得到解决方案。您必须修复您的html。你不能让他进来。代码引用:这是错误的。您在java中使用了tr:iterator,所以任何其他方法都可以得到解决方案。您必须修复您的html。你不能让他进来。我们是否有机会在需要查看更多行时显示标题。同样的按钮也要像隐藏一样放置。当需要查看更多行时,我们是否有机会显示标题。同样的按钮也要像隐藏一样放置。