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

jquery method to determine whether an element is visible

藏色散人
Release: 2023-01-04 09:36:41
Original
3595 people have browsed it

The implementation method of jquery to determine whether an element is visible: first select the element to be determined; then use "is()" with the ":visible" selector to determine whether it is visible. The syntax is such as "$(selector). is(":visible")".

jquery method to determine whether an element is visible

The operating environment of this tutorial: windows7 system, jquery1.10.0 version, thinkpad t480 computer.

Recommended: "jquery video tutorial" "javascript basic tutorial"

jquery determines whether an element is visible

The method is very simple, select the element you want to judge, and then use is() with the :visible selector to judge whether it is visible; syntax $(selector).is(":visible").

is() method users check whether the selected element is equipped with a selector; the :visible selector selects each element that is currently visible.

Code to determine whether it is visible:

if($('#div').is(':visible')){
      //如果显示时。。。
}else{
      //如果隐藏时。。。
}
Copy after login

Description:

Elements other than the following situations are visible elements:

Set to display :none

type="hidden" form elements

Width and height are set to 0

Hidden parent elements (all child elements are hidden at the same time)

The above is the detailed content of jquery method to determine whether an element is visible. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!