Identify a specific image, upload, then do something ...

I'm slowly pondering JS / Jquery and I need help / guidance on detecting when a "specific" image is "visible" so I can remove the class on another element. I'm just sure ... just trying to figure out the logic.

JS. ...

$('.my-big-hero').find('my-image-here.jpg:visible').removeClass('class-i-want-removed');

      

This is probably an easy (and wrong way) to display this, but it should give you an idea of ​​what I am trying to achieve. I've tried different ways to write this and not win.

Appreciate any help you can give .... thanks in advanced.

+3


source to share


2 answers


You can use functions .is("visible")

and toggleClass

thus:

$('.my-big-hero').find('my-image-here.jpg').toggleClass('class-i-want-removed', !$(this).is(':visible'));

      



Then the element will have a class class-i-want-removed

if it is not visible, and the class will be removed after it is visible.

+1


source


Using JQuery you can do something like this:



$(".my-big-hero").find("my.image.here.jpg").on("load", function() {
   $(this).removeClass("class-i-want-removed");
});

      

0


source







All Articles