Home >Web Front-end >JS Tutorial >jquery method to determine whether an element is visible
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")".
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!