Forum Moderators: open
<script>
function describe(x) {
var description;
for (i = 0; i < x.parentNode.childNodes.length; i++) {
if (x.parentNode.childNodes[i].className == "sessiondescription") {
description = x.parentNode.childNodes[i];
break;
}
}
if (description.style.display == 'block') {
description.style.display = 'none';
return;
firstCell.className = 'start';
secondCell.className = 'end';
} else {
description.style.display = 'block';
return;
}
}
</script>
css:
.sessiondescription
{
display: block;
font: Arial;
font-size: 9pt;
font-weight: normal; margin: 5px 0;
}
}
firstCell and secondCell will never get set in this condition, move return to the end.
if (description.style.display == 'block') {
description.style.display = 'none';
firstCell.className = 'start';
secondCell.className = 'end';
return;
}
Any advice on how to show layer by default would be appreciated:
.....
changing the .sessiondescription element to "none" doesn't create the change of open layer on page load.
Likely because Javascript isn't "aware" of an element's properties unless the properties are inline. See this thread [webmasterworld.com] for details. Also recently discussed in this thread [webmasterworld.com]. So if you were to put an alert here,
.....
description = x.parentNode.childNodes[i];
break;
}
alert(description.style.display);
}
if (description.style.display == 'block') {
.....
The alert may very well say "undefined" (good test to see what's going on.)
Try the following. You can use methods to get at the element by class name but I'm using getElementByID here for example, which is easier to target unique elements. You can just add an ID attribute to the element.
<p id="sessiondesc" class="sessiondescription">blah</p>
<script type="text/javascript">
window.onload=function() {
if (document.getElementById('sessiondesc') {
getElementById('sessiondesc').style.display='none';
}
};
function describe(x) {
............
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script><script>
$(document).ready(function(){
$(document.body).click(function () {
if ($("div:first").is(":hidden")) {
$("div").slideDown("slow");
} else {
$("div").hide();
}
});});
</script>
<style>
div { background:#de9a44; margin:3px; width:80px;
height:40px; display:none; float:left; }
</style>
</head>
<body>
Click me!
<div></div>
</body>
</html>