Reputation: 43647
How do I check if the opacity of an element is 0, and then do something in jQuery?
Upvotes: 30
Views: 45997
Reputation: 42818
To find opacity you do
var x = $('#test').css('opacity');
x==0 ? alert('opacity is 0') : alert('Opacity is not 0');
Upvotes: 1
Reputation: 21854
You can do as
$(function() {
if ($('#foo').css('opacity') == 0)
alert('lol');
});
Demo : http://jsfiddle.net/9GEZ5/
Upvotes: 2
Reputation: 2104
var currentOpacity = jQuery.fx.step.opacity if(currentOpacity == 0) { ...
Upvotes: 0
Reputation: 3325
if( $("#id_of_your_thing").css('opacity') == "0" )
do_stuffs();
Upvotes: 1
Reputation: 8125
Have you tried using .css()?
if($('elemFoo').css('opacity') == 0) {
doSomething();
}
Upvotes: 68