Harry F
Harry F

Reputation: 122

jQuery - opacity not being applied

I have a strange problem where I'm trying to use jQuery to set the opacity to 1.0 on an image I'm fading in, but it's not overriding the existing CSS opacity setting of 0.2. If i change the jquery to set another css style on the element being faded in, it works fine, but for some reason the opacity rule isn't working! Can anyone see what might be happening here?

// obj is the container div    

$('.mosaic_list.mosaic_img:not(.mosaic_last_img)',obj)
    .random(1)
    .appendTo(mosaic_box)
    .fadeIn(5000)
    .css('opacity', 1.0);


// just to show where mosaic_box var is assigned
    var mosaic_box = $('.mosaic_box:not(.mosaic_last_box):not(.mosaic_hover)', obj).random(1);

Upvotes: 1

Views: 167

Answers (1)

Shai Mishali
Shai Mishali

Reputation: 9382

Did you consider using .fadeTo ?

$('.mosaic_list.mosaic_img:not(.mosaic_last_img)',obj)
    .random(1)
    .appendTo(mosaic_box)
    .fadeIn(5000)
    .fadeTo('slow', 1.0);

Shai.

Upvotes: 2

Related Questions