Question on style.display



I have this test code

<html>
<head>
<style type="text/css">
#divx {display: none}
</style>
</head>
<body>
<div id="divx">This div section is not displayed!</div>
<script>
alert ('style.display=' +document.getElementById('divx').style.display)
</script>
</body>
</html>

If I type
#divx {display: block}
the CSS is applied in that the contents <div id="divx"> is displayed,
but the alert displays
'style.display=' (After the = sign there is nothing/blank/zilch.)

If I type
#divx {display: none}
the CSS is applied in that the contents <div id="divx"> is not displayed,
the alert displays
'style.display=' (After the = sign there is nothing/blank/zilch.)

The CSS is applied in that 'block' will display the contents of the <div>
and 'none' will not,
BUT the alert does NOT display 'none' 'block' or whatever is typed into
#divx {display: ....}

If I alter the <script> to read
<script>
document.getElementById('divx').style.display='none'
alert ('style.display=' +document.getElementById('divx').style.display)
</script>
OR
<script>
document.getElementById('divx').style.display='block'
alert ('style.display=' +document.getElementById('divx').style.display)
</script>
I get the correct result

Is the JS application of style.display different from that of CSS ?

--
Trevor Lawrence
Canberra
Web Site http://trevorl.mvps.org


.



Relevant Pages

  • Re: How to set the message displayed when a Perl Script fails compilation?
    ... might reveal sensitive information, ... does typically not display "a friendly page" to a visitor, ... does not alert the script author if the error happens when a visitor uses the script. ...
    (comp.lang.perl.misc)
  • undefined field error message
    ... I have a script that is supposed to check if one of the radio buttons ... in a form is checked and either display an "alert" or go to another ...
    (comp.lang.javascript)
  • Re: Internet Explorer - Firefox
    ... Firefox, the problem is how publisher displayed it in IE. ... I imagine it is a problem with how the script is ... suppose to display a search box for flights..i am pretty sure that the ...
    (microsoft.public.publisher.webdesign)
  • Re: Display a block of text in Firefox & Safari
    ... in FireFox and Safari it appears as a narrow ... There seems to be a needless reliance on the global variable 'NumberOfQuestionsShown', I've suggested a different strategy below that should be easier to maintain - it uses a single class to hide/show questions so the script doesn't need to know how many questions there are nor do they need to be consecutively numbered. ... var questionNum; ... Instead of going through all questions, how about giving them all the same style, then just modify the style to change display from 'none' to ''. ...
    (comp.lang.javascript)
  • Re: Conditional formatting
    ... happens if you step through the script in Script Debugger? ... I'd like to dynamically place a button on my layout. ... I only want the "Show All" button to display when I'm ... calculation determining how the button is labelled and describing what ...
    (comp.databases.filemaker)