James
James

Reputation: 43647

Check opacity by jQuery

How do I check if the opacity of an element is 0, and then do something in jQuery?

Upvotes: 30

Views: 45997

Answers (6)

Mark
Mark

Reputation: 3474

jquery.support.opacity

on jQuery 1.7.1 seems to work

Upvotes: 0

Hussein
Hussein

Reputation: 42818

To find opacity you do

var x = $('#test').css('opacity');
x==0 ? alert('opacity is 0') : alert('Opacity is not 0');

Check working example at http://jsfiddle.net/SCHNc/1/

Upvotes: 1

GG.
GG.

Reputation: 21854

You can do as

$(function() {

    if ($('#foo').css('opacity') == 0)
        alert('lol');

});

Demo : http://jsfiddle.net/9GEZ5/

Upvotes: 2

ukhardy
ukhardy

Reputation: 2104

var currentOpacity = jQuery.fx.step.opacity

if(currentOpacity == 0)
{
   ...

Upvotes: 0

Groovetrain
Groovetrain

Reputation: 3325

if( $("#id_of_your_thing").css('opacity') == "0" )
  do_stuffs();

Upvotes: 1

Christian Mann
Christian Mann

Reputation: 8125

Have you tried using .css()?

if($('elemFoo').css('opacity') == 0) {
    doSomething();
}

Upvotes: 68

Related Questions