sukebe7
sukebe7

Reputation: 89

Hiding nth-child of a specific table

I have two tables on a page. How do I address the second one, id="tapp", to run show/hide nth-child functions?

I've ignorantly tried to address the particular table by adding the id reference to the beginning of 'td:nth-child...'

...
var x = document.getElementById("tatt");
$(x.'td:nth-child(3),th:nth-child(3)').hide();
...

Upvotes: 0

Views: 856

Answers (2)

Mamun
Mamun

Reputation: 68923

You can precede the selector by id in each comma separated group. Try

$('#tatt td:nth-child(3), #tatt th:nth-child(3)').hide();

Note: Why you are using getElementById() when you already have jQuery?

Upvotes: 1

mbojko
mbojko

Reputation: 14679

Rather something like

$('#tatt').find('td:nth-child(3), th:nth-child(3)').hide();

or

$('#tatt td:nth-child(3), #tatt th:nth-child(3)').hide();

(BTW, if you're using jQuery for DOM manipulation, there's really no need to call the findElementById method, too. Just stick to $(/*selector*/).

Upvotes: 0

Related Questions