-3

i have a following div

   <div id="mydiv" style="position: absolute; top: 60px; 
                  left: 5px; right: 25px; bottom: 10px;"> 
   </div>

Then i hide it via JS with display none. Is it possible to display it back again? None of the display attributes work. Thank you

Murali Murugesan
  • 22,423
  • 17
  • 73
  • 120
azza idz
  • 623
  • 3
  • 13
  • 27

7 Answers7

2

It can be very easily done using jQuery,

 1. $('#my_div').show()   // display the hidden div i.e sets display:block
 2. $('#my_div').toggle() // toggles the display property.

And using pure javascript it can done using,

var element = document.getElementById('myDiv'); 

element.style.display = 'block'; // sets display:block
Deepak Ingole
  • 14,912
  • 10
  • 47
  • 79
0

The default value for the display property is 'block', so just set it back to that:

var d = document.getElementById('my_div');

d.style.display = 'block';

Edit:

My fellow answerer has given a link to W3Schools, so I thought I'd do one better and send you to WebPlatform.org, which is a community-driven documentation for the web.

shennan
  • 10,798
  • 5
  • 44
  • 79
0
var el = document.getElementById('example-element');

el.style.display = 'none';

el.style.display = 'block';

For more options, check it out.

Roy Miloh
  • 3,381
  • 1
  • 18
  • 17
0

Try this one:

$("#mydiv").css("display","block");
Shahbaz Chishty
  • 482
  • 1
  • 4
  • 9
0

Try like this.

$('#my_div').show()
Anil kumar
  • 4,107
  • 1
  • 21
  • 36
0

to hide and show , you can probably use visibility: visible/hidden, which basically divs will be there but will be hide/show.

pappu_kutty
  • 2,378
  • 8
  • 49
  • 93
0

If you display and hide this div on some action (e.g. on mouseover, onclick etc.) you can simply use toggleClass with jquery

css:

.display{display:block}

js:

$("#mydiv").toggleClass('display')

Mukesh Ram
  • 6,248
  • 4
  • 19
  • 37
Anna Gabrielyan
  • 2,120
  • 3
  • 28
  • 48