I'm a beginner when it comes to Javascript, and I'm still getting the hang of CSS/HTML. Currently, I am working on creating a vertical menu using CSS and javascript. My goal is to have the sublevels appear on the right side of the menu when someone clicks on the appropriate title. I have successfully implemented the functionality for the first sublevel. It shows up and disappears when its 'parent' is clicked. However, whenever I attempt to click on a title within the sublevel, the sublevel closes instead of opening the next one. I know there must be an error in my approach, but I can't seem to figure out what it is :( I've compiled all of my code here: http://jsfiddle.net/kyqJ6/, but for some reason, it doesn't work there even though I copied it exactly as is. Here's an example of the javascript segment:
function dropdown1()
{
if(document.getElementById('menu1').style.display=='block'){
document.getElementById('menu1').style.display='none';
}
else{
document.getElementById('menu1').style.display='block';
}
};
I understand that there may be mistakes in my code and many areas where improvements could be made. Please don't hesitate to point those out. However, at this point, what I really need help with is resolving the issue mentioned above :) Thank you for taking the time to read this, and in advance, thank you for any help or advice you can provide!