Tuesday, 27 August 2013

display = 'none' does not work in javascript

display = 'none' does not work in javascript

I want to hide divA and show divB. If I click a button I want to hide divB
and show divA. I don't want to use JQuery.
I have troubles hiding divA when the page loads. When I click the button,
the divB is hidden correctly.
I added this in the beginning of the document
<script>
var doNotShow= document.getElementById('divA');
doNotShow.style.display = 'none';
</script>
The thing is, it does not work. The weird thing is that when later, I try
to hide divB via a button click then divB hides as it should. The divA is
after the javascript part in the file.

No comments:

Post a Comment