Question on style.display
- From: "Trevor Lawrence" <Trevor L.@Canberra>
- Date: Sun, 19 Oct 2008 15:40:40 +1100
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
.
- Follow-Ups:
- Re: Question on style.display
- From: Anthony Jones
- Re: Question on style.display
- From: Dave Anderson
- Re: Question on style.display
- Prev by Date: cross-domain problem
- Next by Date: Re: Question on style.display
- Previous by thread: cross-domain problem
- Next by thread: Re: Question on style.display
- Index(es):
Relevant Pages
|