Home  >  Article  >  Web Front-end  >  jquery method to determine whether an element is visible

jquery method to determine whether an element is visible

藏色散人
藏色散人Original
2020-12-09 09:39:203619browse

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{
      //如果隐藏时。。。
}

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!

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