Home  >  Article  >  Web Front-end  >  How to hide a div in jquery

How to hide a div in jquery

青灯夜游
青灯夜游Original
2022-02-28 15:01:468326browse

Jquery method to hide a div: 1. Use the "$("div").hide();" statement to hide; 2. Use the "$("div").toggle();" statement Hide; 3. Use the "$("div").css("display","none");" statement to hide.

How to hide a div in jquery

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

jquery method to hide div

Method 1: Use hide() method

hide () method can hide selected elements.



	
		
		
	

这是一个标题

这是一个div元素。

这是另一个段落。

How to hide a div in jquery

Method 2: Use the toggle() method

toggle() method to switch the visible state of the element.

If the selected elements are visible, then hide these elements. If the selected elements are hidden, then display these elements.



	
		
		
	

这是一个标题

这是一个div元素。

这是另一个段落。

How to hide a div in jquery

Method 3: Use the CSS() method to set the display attribute to the element



	
		
		
	

这是一个标题

这是一个div元素。

这是另一个段落。

How to hide a div in jquery

[Recommended learning: jQuery video tutorial, web front-end video

The above is the detailed content of How to hide a div in jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn