yukashima huksay
yukashima huksay

Reputation: 6248

how does jQuery fade elements?

I need to select the <img> tags that are already faded with jQuery fadeOut() . my idea is to select them with css attribute selector like this: img[attr="smth"] . but i don't know what is the jQuery's algorithm to fade elements out and i don't know it turns which attribute's value to what in order to fade elements. I have tried:

Console.log($("img").attr("opacity"));
Console.log($("img").attr("display"));
Console.log($("img").attr("visibility"));

But for all of them console says, undefined. Does anyone know what attribute i should use? Does anyone know any other way to do this without using css attribute selector?

Upvotes: 0

Views: 82

Answers (3)

kiranvj
kiranvj

Reputation: 34147

var arrFadedElements = [];

// update YOUR-SELECTOR
$(".YOUR-SELECTOR").fadeOut(function() {
 arrFadedElements.push($(this));
});

console.log(arrFadedElements)

Upvotes: 1

josegomezr
josegomezr

Reputation: 916

I suggest you to add a class just when fading the element. Something like this:

// ... is your selector
$(...).fadeOut().addClass('img-faded');

After that you'll be able to fetch all faded images with:

var fadedImgs = $('img.img-faded');

Upvotes: 3

b3da
b3da

Reputation: 583

fadeIn():

display:none;

opacity going from 0 to 1 in defined timeframe

display: block or inline etc..

opacity is happening only for a fragment of second (by default). You can check how is it working by inspecting element in your browser ;)

Upvotes: 1

Related Questions