First: Use CSS attributes
Copy codeThe Code is as follows:
Var display variables ('your id'}.css ('display ');
If (display = 'None '){
Alert ("you have discovered it. I am hiding it! ");
}
Type 2: Use the jquery built-in Selector
Suppose our page has such a tag,
Copy codeThe Code is as follows: <div id = "test">
<P> only used for testing </p>
</Div>
Then, we can use the following statement to determine whether the tag with id "test" is hidden:
Copy codeThe Code is as follows: if ($ ("# test"). is (": hidden") {...} // provided that the jQuery library has been imported
In this way, we can easily determine whether an element is hidden and set an animation based on its state, for example:
Copy codeThe Code is as follows:
If ($ ("# test"). is (": hidden ")){
$ ("# Test"). show (); // If the element is hidden, it is displayed
} Else {
$ ("# Test"). hide (); // hide an element if it is displayed
}