0

How do I hide a certain label dynamically along with it's leading th tag?

example:

<th class="woo_metabox_names"><label for="woothemes_size">sq ft</label></th>

I tried and this doesn't work, by the way:

$('label[for="woothemes_size"]').hide();
0

1 Answer 1

1

To hide both the label and th elements, you can use:

$('label[for="woothemes_size"]').parent().hide();
Sign up to request clarification or add additional context in comments.

4 Comments

Why bother hiding the child element? It will be hidden with the parent
@Phil Ha! Good point. Can't believe I didn't see that. Although there might be some reason why you'd want to hide both individually (since what it really does is change the display to none for each element that hide is called on), but you're probably right.
$('label[for="woothemes_size"]').closest('th').hide(); should be good enough right ??
@Sushanth-- Yeah that works too. I don't know which is better. I like using things that assume certain things about the structure of the DOM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.