![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| ||||
| ||||
|
|
Hello, I have the following function: Code:
|
I think it is better to use: var i = allIds.length; while (i--) { ids = allIds[i]; or var i = allIds.length; while (i) { ids = allIds(--i); or var i = allIds.length; do { ids = allIds(--i); ... } while (i); The last one shouldn't be used if the length of allIds has a chance of being zero.To answer your question below, try (wrapped for posting): document.getElementById('d' + ids).style.display = (('d' + ids) == id)? '' : 'none'; document.getElementById('a' + ids).style.display = (('a' + ids) == id)? '' : 'none'; When you want to show the element, don't set the display property value to 'block', set it to '' (empty string) so that the value can return to whatever it is by default or inheritance.Quote:
{ document.getElementById(ids).style.display=ids==id?'block':'none'; Quote:
} }
| I have 6 divs with Ids 'dHome', 'dBiografia', ... And 6 anchors with Ids 'aHome', 'aBiografia', ... So when I do show('Home') I want to: 1. Show dHome and hide all the other divs from the list 2. Hide aHome and show all the other anchors from the list |
![]() |
| Thread Tools | |
| Display Modes | |
| |