Home > Web Front-end > JS Tutorial > body text

jQuery :Introduction to how to use the visible selector

黄舟
Release: 2017-06-23 11:54:52
Original
1557 people have browsed it

Overview

Match all visible elements

Example

Description:

Find all visible tr elements

HTML code :

<table> 
<tr style="display:none">
<td>Value 1</td>
</tr> <tr>
<td>Value 2</td>
</tr> 
</table>
Copy after login

jQuery Code:

$("tr:visible")
Copy after login

Result:

[ <tr><td>Value 2</td></tr> ]
Copy after login

This selector matches all currently visible elements.

Grammar structure:

$(":visible")
Copy after login

This selector is generally used in conjunction with other selectors, such as Class selector and Element selector, etc. wait. For example:

$("div:visible").css({color:"blue"})
Copy after login

The above code can set the font color in the visible div element to blue.
If not used with other selectors, the default state is used with the * selector, for example, $(":visible") is equivalent to $("*:visible").

Example code:

Example 1:












我是不可见的
我是可见的
  • php中文网欢迎您
Copy after login

##The above code can set the text color in the visible div is blue.

Example 2:






脚本之家





我是不可见的
我是可见的
  • 脚本之家欢迎您
Copy after login
Since the above code does not specify a selector to be used with the :visible selector, it is used with the * selector by default, so the code can select all visible The text color in the element is set to blue.

The above is the detailed content of jQuery :Introduction to how to use the visible selector. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Previous article:Detailed explanation of jquery :hidden selector selecting