Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a div with jQuery?

When I want to hide a HTML <div>, I use the following JavaScript code:

var div = document.getElementById('myDiv'); div.style.visibility = "hidden"; div.style.display = "none"; 

What is the equivalent of that code in jQuery?

like image 468
kamaci Avatar asked Mar 21 '11 08:03

kamaci


People also ask

How do I completely hide a div?

The hidden attribute hides the <div> element. You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <div> element is not visible, but it maintains its position on the page.

Can you hide a div in JavaScript?

To hide a div using JavaScript, get reference to the div element, and assign value of "none" to the element. style. display property.

What does jQuery hide () do?

jQuery hide() Method The hide() method hides the selected elements. Tip: This is similar to the CSS property display:none. Note: Hidden elements will not be displayed at all (no longer affects the layout of the page). Tip: To show hidden elements, look at the show() method.

How can remove hidden div in jQuery?

You must toggle it with a boolean true or false . . attr("hidden", false) will remove the attribute the same as using . removeAttr("hidden") .


1 Answers

$('#myDiv').hide(); 

or

$('#myDiv').slideUp(); 

or

$('#myDiv').fadeOut(); 
like image 175
Sujit Agarwal Avatar answered Sep 24 '22 02:09

Sujit Agarwal