Abdul Rahman
Abdul Rahman

Reputation: 1705

Hide first row of html table 2 having no class and no id attributes

i have two html tables in iframe tag, having no class nor id attributes. I am trying to use jQuery to find the second table first row and hide it? my tables are looks like this: Note: basically I have two tables, and both the tables are inside the iframe tag. I need to hide the second table first row?

<table>
  <tr>
        <td> 1 </td>
         .
         .
         .
 </tr> 
</table>

I need to hide the first row of the following table:

<table>
   <tr>
     <td> This row i need to hide() </td>
   </tr>
  </table>

I have tried too may ways like this:

      $( "table[1] tr:first" ).css("display", "none" );

but having no results... Please help.

Upvotes: 0

Views: 2749

Answers (4)

KooiInc
KooiInc

Reputation: 122906

Adjusted cf comment (jsfiddle also modified)

See this jsFiddle for $('table').eq(1).find(tr:first').hide();

As far as I understand (from OPs comment on @DavidThomas' answer) the table resides within an iframe. You'll need to get the contents of that frame first, something like

    var framebody = $($('iframe')[0].contentDocument.body)
       ,frameSecondTable = framebody.find('table').eq(1);

The jsFiddle shows the workings of that.

Upvotes: 1

David Thomas
David Thomas

Reputation: 253318

I'd suggest, on the assumption the <table> elements aren't siblings:

$("table").eq(1).find("tr:first").hide();

Solutions using the selector :nth-child(2) will only work if the second <table> is the second child of its parent, and will select every t<table> that is the second child of its parent.

Upvotes: 3

MH2K9
MH2K9

Reputation: 12039

You can use nth-child and jQuery hide

$( "table:nth-child(2) tr:first" ).hide();

Upvotes: 0

frogatto
frogatto

Reputation: 29285

Try this :

 $( "table:nth-child(2) tr:first" ).css("display", "none" );

Upvotes: 0

Related Questions