First: Using CSS Properties
Copy CodeThe code is as follows:
var display =$ (' #id '). CSS (' Display ');
if (display = = ' None ') {
Alert ("You found out, I was hidden!") ");
}
The second type: using the jquery built-in selector
Let's say we have this label on our page,
Copy CodeThe code is as follows: <div id= "Test" >
< p> is just for testing </p>
</div>
Then, we can use the following statement to determine whether the tag ID "Test" is hidden:
Copy CodeThe code is as follows: if ($ ("#test"). Is (": hidden")) {...}//provided that the library of jquery has been directed in
In this way, we can easily determine if an element is hidden and animate according to its state, such as:
Copy CodeThe code is as follows:
if ($ ("#test"). Is (": hidden")) {
$ ("#test"). Show (); If the element is hidden, it appears
}else{
$ ("#test"). Hide (); If the element is visible, it is hidden
}
jquery Determines whether the element shows whether it is hidden
Copy CodeThe code is as follows:
var node=$ (' #id ');
The first form of a notation
Copy CodeThe code is as follows:
if (node.is (': Hidden ')) {//If node is hidden, the node element is displayed, otherwise hidden
Node.show ();
}else{
Node.hide ();
}
The second type of notation
Copy CodeThe code is as follows:
if (!node.is (': Visible ')) {//If node is hidden, the node element is displayed, otherwise hidden
Node.show ();
}else{
Node.hide ();
}
if (node.is (': Visible ')) {//Hide the node element if node is displayed, otherwise display
Node.hide ();
}else{
Node.show ();
}
jquery determines whether objects are displayed or hidden
JS Code
Copy CodeThe code is as follows:
JQuery ("#tanchuBg"). CSS ("display")
JQuery ("#tanchuBg"). Is (": visible")
JQuery ("#tanchuBg"). Is (": hidden")
JS Code
Copy CodeThe code is as follows:
$ (Element). Is (": visible")//Checks for Display:[none|block], ignores Visible:[true|false]
JS Code
Copy CodeThe code is as follows:
$ (' Element:hidden ')
$ (' element:visible ')
JS Code
Copy CodeThe code is as follows:
$ (". Item"). each (function ()
{
if ($ (this). CSS ("visibility") = = "hidden")
{
Handle non visible state
}
Else
{
Handle Visible state
}
})
JS Code
Copy CodeThe code is as follows:
AR isVisible = $ (' #myDiv '). Is (': visible ');
var Ishidden = $ (' #myDiv '). Is (': hidden ');
JS Code
Copy CodeThe code is as follows:
if ($ (this). CSS ("display") = = ' None ') {
/* Your code here*/
}
else{
/* Alternate logic */
}
Determine if the jquery element is hidden