Home  >  Article  >  Web Front-end  >  jQuery :Introduction to how to use the visible selector

jQuery :Introduction to how to use the visible selector

黄舟
黄舟Original
2017-06-23 11:54:521554browse

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>

jQuery Code:

$("tr:visible")

Result:

[ <tr><td>Value 2</td></tr> ]

This selector matches all currently visible elements.

Grammar structure:

$(":visible")

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"})

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中文网欢迎您

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

Example 2:






脚本之家





我是不可见的
我是可见的
  • 脚本之家欢迎您

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn