1

I'm trying to find all elements that have a filter style applied to them from a CSS file.

For instance

.fourty {

    filter:alpha(opacity=40);
}
.fifty {

    filter:alpha(opacity=50);
}
.sixty {

    filter:alpha(opacity=60);
}

How would I capture those elements?

2 Answers 2

1

How about add class to the elements which has filter ?
Then you can do the following:

var $elements = $('.yourClass');

Or you can do the following if you don't want to add a class.

var $elements = $('*').filter(function() {
    return $(this).css('filter') != 'auto';
});

I suggest you to add opacity to the css, because filter isn't crossbrowser. So your code should be the following.

var $elements = $('*').filter(function() {
    var $element = $(this);
    return $element.css('filter') != 'auto' || $element.css('opacity') != 1;
});

demo

Sign up to request clarification or add additional context in comments.

Comments

1
var foundels = [];

$(els).each(function(){
    if($(this).css('filter') == 'alpha(opacity=60)')
        foundels.push(this);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.