You're not using indexOf()
correctly.
// IF STRING CONTAINS .GIF, ADD HYENA CLASS
if( GIFstr.indexOf('.gif') !== -1 ) jQuery(this).addClass('hyena');
문제
Hi I'm tearing my hair out with this code. Im trying to get it to only target my GIFS because the plugin is working on everything I post. I'm using HEADWAY and I have this in my footer.
<script>
jQuery(document).ready(function(){
jQuery('body .post img').each(function(){
// GET IMG SRC ATTR AS A STRING
var GIFstr=jQuery(this).attr('src').toLowerCase();
// IF STRING CONTAINS .GIF, ADD HYENA CLASS
if( GIFstr.indexOf('.gif') ) jQuery(this).addClass('hyena');
});
});
</script>
Im trying to get it to only target my GIFS because the plugin is working on everything post.
Thanks.
해결책
You're not using indexOf()
correctly.
// IF STRING CONTAINS .GIF, ADD HYENA CLASS
if( GIFstr.indexOf('.gif') !== -1 ) jQuery(this).addClass('hyena');