Selecting Elements Based on Their Visibility - J Query

Problem
You need to select an element based on whether it’s visible.

Solution

You can use either the :hidden or :visible filter as necessary:

Here are some other examples of usage:

Discussion

If you need more control, you can always use jQuery’s filter() method, which allows you to test the element in any way you want. For example, you may want to select all elements that are set to display:none but not those that are set to visibility:hidden. Using the :hidden filter won’t work because it matches elements with either of those characteristics (< v1.3.2) or doesn’t take either property into consideration at all

The preceding code should leave you with a collection of elements that are set to display:none but not visibility:hidden. Note that, usually, such a selection won’t be necessary the :hidden filter is perfectly suitable in most situations.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

J Query Topics