GoDxNero Posted June 7, 2009 Share Posted June 7, 2009 Well I am currently using this java script: function toggle(element) {if (document.getElementById(element).style.display == "none") { document.getElementById(element).style.display = "block"; } else { document.getElementById(element).style.display = "none"; }} How can I make it so that when I start a new function toggle, the previous ones get reset back to invis ? What I mean is that if I got 2+ div ( all vision = invisible ) . Once I click on the first button the first div will appear and when I click the second button the second div will appear together with the first and just like that with the third div and so on... But I want so that once I click the other button it will be the only one that show up and the rest which vision=visible turn back to invisible. Do you guys know a methods work with alots div this way ? Thanks alots in advance ! Link to comment Share on other sites More sharing options...
Ingolme Posted June 8, 2009 Share Posted June 8, 2009 You can use the for() loop to loop through all the other divs and make them invisible. Link to comment Share on other sites More sharing options...
GoDxNero Posted June 8, 2009 Author Share Posted June 8, 2009 Srry I am such a newbie ... tried countless time but cant seem to be able to solve the probleem on my own. Checked many forums on google but haven't found any answer . Please give me few hints how to solve it Link to comment Share on other sites More sharing options...
justsomeguy Posted June 8, 2009 Share Posted June 8, 2009 Look up examples for document.getElementsByTagName, or simply add a line to explicitly disable each div by ID. Link to comment Share on other sites More sharing options...
Jonas Posted June 9, 2009 Share Posted June 9, 2009 You could also have a look at the show/hide script here, along with other javascript snippets:http://w3schools.invisionzone.com/index.php?showtopic=9500Shown in practice here:http://www.iribbit.net/i/_files/javascript-snippets.htm Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.