addClass and removeClass works but changes are not seen by jQuery functions.
Hello!
I'm building a gallery and i have a couple of thumbnails.
There is always 1 active thumbnail (opacity 100%) of the showing image and several inactive thumbnails (opacity 50%).
I've build some functions to catch clicks for those functions:
- $(document).ready(function() {
-
- $(".galleryinactivethumb").click(function(){
- $(".galleryactivethumb").removeClass('galleryactivethumb').addClass('galleryinactivethumb');
-
- $(this).removeClass('galleryinactivethumb').addClass('galleryactivethumb');
-
- alert("inactive thumb clicked!");
- return;
- });
-
- $(".galleryactivethumb").click(function(){
-
- alert("active thumb clicked!");
- return;
- });
-
- jQuery('.galleryinactivethumb').each(function() {
-
- $(this).hover(function() {
- //Hover out
- $(this).stop().animate({ opacity: 1.0 }, 500)
- },
-
- function() {
- //Hover on
- $(this).stop().animate({ opacity: 0.5 }, 500);
- ;
- });
-
- });
When i click an inactive thumb the classes are changes to the correct classes (safari/chrome's webinspector shows the change in the classes) but when i then click the same thumb again it run's the function of the previous class(witch was removed jus a second ago).
Am i doing something wrong here?
I can't get it to work!
Can someone help me with this?
Thanks!