Jquery method to determine whether an element is hidden: 1. Use CSS attributes, the code is [var display =$('#id').css('display')]; 2. Use jQuery to determine whether the object is displayed Grammar, the code is [$(".test").css("display].
The operating environment of this tutorial: Windows 7 system, jquery version 2.2.4, This method is applicable to all brands of computers.
Jquery method to determine whether an element is hidden:
1. Use CSS attributes
var display =$('#id').css('display'); if(display == 'none'){ alert("none为隐藏"); }
2. jQuery determines elements
var node=$('#id');
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.hide(); }else{ node.show(); }
3.jQuery determines objects Whether to display syntax
$(".test").css("display") $(".test").is(":visible") $(".test").is(":hidden") $(element).is(":visible") // 返回值 display:[none|block], hidden和visible:[true|false]
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!