<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#b {
display: none;
}
</style>
<script type="text/javascript">
document.getElementById("b").style.display = block;
</script>
</head>
<body>
<h1 id="b">Hello</h1>
</body>
</html>
Does anyone know what I'm doing wrong here? Shouldn't the CSS be changed by the javascript and display Hello. Thanks for any help!
.style.<style>works only for inline styles. You should also wait until document is ready. Place script inside bodyblockto"block", you aren't referencing a variable. And place your script after the body closing tag, that way it will be executed after parsing the HTML (the element "is there" to be selected by your code).