arbitter Posted November 14, 2010 Share Posted November 14, 2010 Hi there, I'm quite new to javascript, but I'm starting to udnerstand the things. The problem I have is simple; I have 2 div's that can be hidden or shown, with id's "sub1" and "sub2". Now, if my page is in a subcategory, that list should be shown, though this is only the case with sub1, since sub2 is a simple login-div. This is the code: <script type='text/javascript'> function togglemenu(id) { var object = document.getElementById(id).style if (object.display == "none") { setAllInvisible() object.display = "block" } else if (object.display == "block") { object.display = "none" } } function setAllInvisible() { for(var i=1; i<=2 ; i++) { var object = document.getElementById("sub"+i).style; object.display = "none"; } } function checkMenu() { var Qstring = document.location.search; sInhoud = Qstring.substring (4,11) if(sInhoud == "groepen") { var object = document.getElementById('sub1').style object.display = "block" } } </script> When you click on a div to open a subcategory; it has eg togglemenu('sub1') with the onclick. The body onload has setAllInvisible() and checkMenu(); I've also integrated all this stuff in less functions, but still lags for some reason. Is it because first the server pushes all the info to your pc, and afterwards the javascript starts working? For example http://www.chirotremelo.be/index2.php?fx=groepen&groep=minis; when you click on another subcategory on the left side, you'll see the div's still sliding. Quote Link to comment https://forums.phpfreaks.com/topic/218639-lag-with-showingnot-showing-divs/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.