Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check opacity by jQuery

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

like image 548
James Avatar asked Mar 14 '11 00:03

James


People also ask

What is opacity in jQuery?

jQuery Effect fadeTo() MethodThe fadeTo() method gradually changes the opacity, for selected elements, to a specified opacity (fading effect).

How to use fadeTo in jQuery?

jQuery | fadeTo() with Examples The fadeTo() is an inbuilt method in jQuery which is used to change the opacity of the selected element. Here selector is the selected element. speed: It specifies the speed of the fading effect. opacity: It specifies to fade and this value should must be in between 0.0 and 1.0.

What is opacity in javascript?

Definition and UsageThe opacity property sets or returns the opacity level of an element. The opacity-level of an element describes the transparency-level, where 1 is not transperant at all, 0.5 is 50% see-through, and 0 is completely transparent.


2 Answers

Have you tried using .css()?

if($('elemFoo').css('opacity') == 0) {     doSomething(); } 
like image 91
Christian Mann Avatar answered Sep 24 '22 13:09

Christian Mann


You can do as

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

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

like image 29
GG. Avatar answered Sep 25 '22 13:09

GG.