<...">

Hide the second and third rows of the table

<div class="NewsResultsList">   
 <table>
        <tr>
            <td>
                Results:<br/>
                First<br/>
                Second          
            </td>
        </tr>
        <tr>
            <td>        
            </td>
        </tr>
        <tr>
            <td>No Results</td>
        </tr>
    </table>
</div>

      

I need to hide the second line and third line.

$('div.NewsResultsList table tr:eq(1)').hide(); 
$('div.NewsResultsList table tr:eq(2)').hide(); 

      

This is not true? What's wrong?

+3


source to share


6 answers


There are several ways to do this:

jsBin demo



$('.NewsResultList tr:gt(0)').hide();

$('.NewsResultList tr').slice(-2).hide();

$('.NewsResultList tr').not(':eq(0)').hide();

$('.NewsResultList tr td:contains("No")').parent('tr').hide();

$('.NewsResultList tr').not(':first').hide();

$('.NewsResultList tr').eq(-1).hide().end().eq(-2).hide();

$('.NewsResultList tr:last').prev().andSelf().hide();

      

+3


source


Use this Script:



    <script type="text/javascript">

        $(document).ready(function (e) {


            $('.NewsResultsList tr:eq(1)').hide();
            $('.NewsResultsList tr:eq(2)').hide();


        });


    </script>

      

+3


source


Your jQuery call is NewsResultList

incorrect. ("NewsResultsList") ...;)

+2


source


You have the wrong selctors to get to these table rows:

In fact it should be

$('div table tr:eq(1)').hide();
$('div table tr:eq(2)').hide(); 

      

DEMO

+2


source


Two questions:

You have NewsResultsList

in your selector but the class NewsResultList

. The two are not the same.

And you are missing </td>

the table.

Fix these two questions and it works here: http://jsfiddle.net/jfriend00/pfemk/

+1


source


Try this in your html / PHP:

 <table>
        <tr>
            <td>
                Results:<br/>
                First<br/>
                Second          
            </td>
        </tr>
        <tr class="hideMe">
            <td> </td>       
            <td></td>
        </tr>
        <tr class="hideMe">
            <td>No Results</td>
        </tr>
    </table>
</div>

      

and this in your jQuery / javascript:

$('#something').click( function() {
    $('.hideMe').hide();
});

      

0


source







All Articles
Results:
First
Second