jQuery judges the display state of the current element and controls the display and hiding of the element

1. jQuery determines whether the current state of an element is displayed or hidden

$(“#id”).is(‘:visible’); //true is displayed, false is hidden

$(“#id”).is(‘:hidden’); //true is hidden, false is displayed

if($(“#id”).is(‘:hidden’)){

// logic code

}

2. jQuery controls the display of css

$(“#id”).show(); //Indicates display:block

$(“#id”).hide(); //Indicates display:none

$(“#id”).toggle(); //Toggle the visible state of the element

$(“#id”).css(‘display’,’none’);

$(“#id”).css(‘display’,’block’);

The post jQuery determines the current element display state and controls the display and hiding of elements first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9161
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment

Your email address will not be published.