jQuery: změna průhlednosti při hoveru (changing opacity on hover) - příklad

Zpět na článek » jQuery: změna průhlednosti při hoveru (changing opacity on hover)

$().ready(function() {
  $('#box img').css('opacity', 0.3);
  $('#box img').each(function() {
    $(this).hover(function() {
    	$(this).stop().animate({ opacity: 1.0 }, 500);
    },
    function() {
    	$(this).stop().animate({ opacity: 0.3 }, 500);
    });
  });
});



Ukázka, co se stane, když vypustíme funkci stop()

$().ready(function() {
  $('#box2 img').css('opacity', 0.3);
  $('#box2 img').each(function() {
    $(this).hover(function() {
    	$(this).animate({ opacity: 1.0 }, 500);
    },
    function() {
    	$(this).animate({ opacity: 0.3 }, 500);
    });
  });
});

Zpět na článek » jQuery: změna průhlednosti při hoveru (changing opacity on hover)