Home > Article > Web Front-end > How to determine whether an element is hidden in jquery
Jquery method to determine whether an element is hidden: 1. If node is hidden, display the node element, otherwise it is hidden. The code is [if(node.is(':hidden'))]; 2. If node If it is displayed, the node element is hidden, otherwise it is displayed.
The operating environment of this tutorial: Windows 7 system, jquery version 3.2.1. This method is suitable for all brands of computers.
How jquery determines whether an element is hidden:
The first way of writing
if(node.is(':hidden')){ //如果node是隐藏的则显示node元素,否则隐藏 node.show(); }else{ node.hide(); }
The second way of writing
if(!node.is(':visible')){ //如果node是隐藏的则显示node元素,否则隐藏 node.show(); }else{ node.hide(); } if(node.is(':visible')){ //如果node是显示的则隐藏node元素,否则显示 node.hide(); }else{ node.show(); }
Related free learning recommendations: javascript(Video)
The above is the detailed content of How to determine whether an element is hidden in jquery. For more information, please follow other related articles on the PHP Chinese website!