jQuery's methods for judging common states such as show and hide
- 2020-05-05 10:53:47
- OfStack
This article illustrates jQuery's methods of judging common states such as show and hide. Share with you for your reference. Here's how:
Display: show() display:block;
Hidden: hide() display:none;
When switching between show and hide, it is necessary to decide whether to show or hide at the moment. The following methods are commonly used to determine the condition:
1.
if(thisNode.is(':hidden')){......}else{.......}
2. First, add the class logo to the Dom element of thisNode. For example, change the logo to class="showFlag"
if(thisNode.hasClass('showFlag')){.......}else{......}
In the same way, you can also determine other contents of thisNode, such as the number of child elements, text contents, and so on, depending on your specific requirements.
I hope this article has been helpful to your jQuery programming.