Tyler L Tyler L - 3 years ago 203
jQuery Question

jQuery select all elements that are visible or have display: none

I'm setting display: none on some elements for mobile, but I still want to select them using jQuery.

I know there's this

$(.connectedSortable[style*="display: none"])


But I'd also like to select the visible elements with class connectedSortable

Answer Source

To select visible elements, you can use the following code snippet.

$(.connectedSortable:visible)

To select hidden elements, you can use the following code snippet.

$(.connectedSortable:hidden)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download