Reputation: 5389
For instance, the code is:
<ul>
<li><strong>This is a list header.</strong> And I want this text to disappear because this is not a list header!</li>
</ul>
And the JavaScript code is:
$('ul li').hide();
$('ul li strong').fadeIn();
What I am trying to achieve is to hide the text that is not inside <strong>
.
Upvotes: 5
Views: 60
Reputation: 7240
Just like Rajaprabhu said, wrap that text inside a span and:
<ul>
<li>
<strong>This is a list header.</strong>
<span>And I want this text to disappear because this is not a list header!</span>
</li>
</ul>
and the js:
$('ul li >').filter(':not(strong)').hide();
Upvotes: 0
Reputation: 67197
Try to wrap that text inside a span
and do,
HTML:
<ul>
<li>
<strong>This is a list header.</strong>
<span>And I want this text to disappear because this is not a list header!</span>
</li>
</ul>
JS:
$('ul li >').hide().filter('strong').fadeIn();
Upvotes: 5