At the moment I am able to hide the image, however then I have no way to show it again.
How can I hide and then be able to show an image when clicking a button using javascript? Here's the button:
|
|||||||||||||||||||||
|
Simply check what the current state is, and then act accordingly.
And a quick note about jQuery to all those suggesting it. For simple things like this, there is no need to include a big DOM manipulation library. If you are doing a lot of DOM manipulations like this in a more complex application, then jQuery starts to make more sense to include. But it's also important to understand what jQuery is doing for you under the hood when you use it. |
||||
The wonders of jQuery - http://jsfiddle.net/PbG3t/
|
|||
If you are using jQuery, you can use the (.toggle) method which simplifies things a lot:
If you want to stick with a hand-crafted solution, I guess your code
is actually missing the deciding bit that sets the element's visibility
back to visible. Try:
|