[Javascript] "display none" to all children
Michael Borchers
list at tridemail.de
Wed May 30 06:07:41 CDT 2007
---- Original Message -----
From: Michael Borchers
To: javascript at LaTech.edu
Sent: Wednesday, May 30, 2007 11:34 AM
Subject: [Javascript] "display none" to all children
I have a main div include several sheets:
<div id="sheet">
<div id="subsheet1"></div>
<div id="subsheet2"></div>
<div id="subsheet3"></div>
</div>
How can I set style.display = 'none'; to all subsheets ("children of sheet") at once?
And is there a way to say: hide all children except f.e. subsheet2 ?
------------------------------------------------------------------------------
I solved it this way so far:
contactsSheets = sheet
The children are f.e. subsheet 1 to 3
<script language="javascript" type="text/javascript">
function showContactsSheets(sheet) {
var contactsSheetsDiv = document.getElementById('contactsSheets');
if (contactsSheetsDiv.hasChildNodes()) {
// Get all children of node
var children = contactsSheetsDiv.childNodes;
// Loop through the children
for(var c=0; c < children.length; c++) {
if(children[c].style) {
children[c].style.display = 'none';
}
}
}
if(sheet != '') {
contactsSheetsDiv.style.display = 'block';
if(document.getElementById(sheet)) {
document.getElementById(sheet).style.display = 'block';
}
}
}
</script>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20070530/a2e1836d/attachment.htm>
More information about the Javascript
mailing list