Javascript 通过 jQuery 检查不透明度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5293680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 16:31:27  来源:igfitidea点击:

Check opacity by jQuery

javascriptjqueryhtmlcssopacity

提问by James

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

如何检查元素的不透明度是否为 0,然后在 jQuery 中执行某些操作?

回答by Christian Mann

Have you tried using .css()?

你试过使用.css()吗?

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

回答by GG.

You can do as

你可以这样做

$(function() {

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

});

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

演示:http: //jsfiddle.net/9GEZ5/

回答by Groovetrain

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

回答by ukhardy

var currentOpacity = jQuery.fx.step.opacity

if(currentOpacity == 0)
{
   ...
var currentOpacity = jQuery.fx.step.opacity

if(currentOpacity == 0)
{
   ...

回答by Hussein

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/

http://jsfiddle.net/SCHNc/1/检查工作示例

回答by Mark

jquery.support.opacity

on jQuery 1.7.1 seems to work

在 jQuery 1.7.1 上似乎工作