Reputation: 153
I have this code:
<li><div class="review-item">
<div class="review-item-thumb"><img width="60" height="60" src="/content/members/av/flags/por-av.png"></div>
<h5>Player <small> Member </small></h5>
<div align="center"></div><font class="fdescrip">No Description!</font></div>
<ul><li><table class="descrip"><tbody><tr><td>
<p><font class="fdescrip">No complete description available.</font></p>
</td></tr></tbody></table></li></ul></li>
I want to remove the font class="fdescrip"
under div class="review-item"
ONLY. I can make both of them dissapear (with $('tag').removeAttr("class");)
but not just one of them as I don't want the second one<p><font class="fdescrip">No complete description available.</font></p>
to be removed.
Any help will be very appreciated! Thanks.
Upvotes: 1
Views: 100
Reputation: 3593
Removes just the CSS class:
$('.review-item > .fdescrip').removeClass('fdescrip');
Removes element from DOM:
$('.review-item > .fdescrip').remove();
Clears the elements content if it's only plain text but leaves it in the DOM:
$('.review-item > .fdescrip').text('');
Upvotes: 1
Reputation: 15860
You can select the first child using,
$('div.review-item .fdescrip:first-child').removeAttr('class');
This way, the jQuery will be applied to the first fdescrip
in the div of review-item and not to any other!
Here is a fiddle for this: http://jsfiddle.net/afzaal_ahmad_zeeshan/Vw7Q8/
Fiddle doesn't remove the class, but it adds there! So you can change it to removeAttr
.
http://api.jquery.com/first-child-selector/
Upvotes: 0