I'm puzzled about a quirk in a web page I'm working on. See how puzzled I am? -->
Here is a snippet of the page:
When the Javascript is executed (in an onclick() action), the expression
comes out with the value "block", which is the value I expect.
So far so good.
However, if I change the page to the following, using named styles instead of anonymous inline classes, then the expression comes out null instead of "block". That's what puzzles me.
By the way, If I change "display:block" to "display:none" in either example, it causes the word "hello" to disappear, so I know my style is in effect. I just can't "see" the "display" setting in the Javascript.
I have the same problem in Safari or in Firefox.
Can somebody explain to me the principle that I'm missing?
Here is a snippet of the page:
Code:
<html>
<head>
<script type="text/javascript">
...document.getElementById('myid').style.display...
</script>
</head>
<body>
<div id="myid" style="display:block">hello</div>
</body>
</html>
Code:
document.getElementById('myid').style.display
So far so good.
However, if I change the page to the following, using named styles instead of anonymous inline classes, then the expression comes out null instead of "block". That's what puzzles me.
Code:
<html>
<head>
<style>
.myclass { display: block }
</style>
<script type="text/javascript">
...document.getElementById('myid').style.display...
</script>
</head>
<body>
<div id="myid" class="myclass">hello</div>
</body>
</html>
I have the same problem in Safari or in Firefox.
Can somebody explain to me the principle that I'm missing?