I have a page with a lot of images. I want to hide those images only if they are gif.
this is the structure:
<div class="wrapper">
<div class="entry">
<div class="image"><img src="imagefile.png" /> </div>
</div>
<div class="entry">
<div class="image"><img src="imagefile.gif" /> </div>
</div>
</div>
I can filter All images this way:
$('.image').closest('.entry').not(".hidewrapper").wrap("<div class='hidewrapper' style=\"display:none\"></div>").closest('.entry').prepend("<a href=\"#\" class=\"unhideImage\" >show me</a>");
Because the site has a lot of images: Is there a way to filter only .gif - files WITHOUT a for-loop? Or am I just completely wrong that loops need much more performance than one-liners?
you can detect it with,
$('div.image img[src$=".gif"]')
Please read here to know more about attribute ends with selector
.
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