I have a list with images, and I need to return a value of those images to then assign some commands. The problem is that in some <li>
there will be a class named off
and needs to be "discarded" from the order.
Sample code:
<ul>
<li class="off">
<img src="image1.jpg" class="imgx" />
</li>
<li>
<img src="image1.jpg" class="imgx" />
</li>
<li class="off">
<img src="image1.jpg" class="imgx" />
</li>
<li class="off">
<img src="image1.jpg" class="imgx" />
</li>
<li>
<img src="image1.jpg" class="imgx" />
</li>
</ul>
That is, I need to list the <img>
that are not within <li class="off">
.
I've tried something like:
var teste = $('li:not(:has(.off)) > img.imgx').eq(1).attr('src');
But it seems that you are not "excluding" those with class off
.