I have a menu that looks like this (1 list item as an example):
<ul class="dyn makeLink" style="display: block;">
<li id="licategory_1">
<a href="/nfl-lines" title="" class="linkItem">
<strong>NFL</strong>
</a>
<span class="expCollPos" >
<span class="collapsed"></span>
</span>
<span class="expCollPos linkItem" >
<span class="collapsed"></span>
</span>
<span class="expCollPos" >
<span class="collapsed"></span>
</span>
</li>
<li id="licategory_2">
...
</li>
</ul>
Which has for some strange reason 3 spans(.expCollPos), the two first ones aren't relevant for me and I'm trying to remove ONLY them using jQuery.
I tried using:
$('.dyn li span.expCollPos:last-child').css("display", "none");
and several others - but it just removes all of the .expCollPos classes.
Am I doing something wrong?
(I got a code that I have to edit and it looks horrable! The javascript functions are unclear and the CSS has so much "!important" that I cant find what's what. )
You want to hide all but the last one, so you have to say not last like
$('.dyn li').find('span.expCollPos:not(:last)').hide();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With