tags:

views:

45

answers:

3

Hi; I have an image gallery and I want to add fade effect, How can I do do this in this code?

$(document).ready(function() {
$(".gallery div").mouseover(function(){
    $(".gallery div").removeClass("current");
    $(this).toggleClass("current");
});
 }); 

Thanks in advance

+2  A: 

Use the fade effect.

You can do fadeIn, fadeOut or fadeTo depending on what you need :

$("p:first").click(function () {
  $(this).fadeTo("slow", 0.33);
});
marcgg
thanks alot Mr. marc
A: 

Something like this, fades out on mouseout, fades in on hover?

$(document).ready(function() {
  $(".gallery div").mouseover(function(){
    $(".gallery div").removeClass("current").fadeTo(500, 0.25);
    $(this).toggleClass("current").stop().fadeIn(200);
  });
});

You can also do this via the hover() function:

$(document).ready(function() {
  $(".gallery div").hover(function(){
    $(this).addClass("current").stop().fadeIn(200);
  }, function() {
    $(this).removeClass("current").fadeTo(500, 0.25);
  });
});
Nick Craver
this code could not stop the fading :(
@jasmine: What result are you seeing? If you can describe it maybe I can help
Nick Craver
@Nick, Thank you very much,Your code fading but not stop the fading in transition
A: 
$(document).ready(function() {
$(".gallery div").hover(function(){
    $(".gallery div").removeClass("current").fadeOut('fast');
    $(this).toggleClass("current").fadeIn('fast');
});
 }); 
prodigitalson
$(document).ready(function() { $(".gallery div").mouseover(function(){ $(".gallery div").removeClass("current"); $(".gImg").fadeTo("slow", 0.33) $(this).toggleClass("current"); });}); this code, fade the .gImg image but " $(".gImg").stop().fadeTo(200);" cant stop fadeIn