The implementation effect is very simple, that is, click to display, and then click to hide, just a few more problems. Well, now let's talk about my design ideas. First, add the following code from the first level.
The Code is as follows:
1
1.1
This shows two categories. Click the parent-Level Display (hidden) sub-level menu, and the JS Code will be in the same sentence:
The Code is as follows:
Function news_pro (o)
{
Var obj = document. getElementById (o)
Obj. style. display = ""? Obj. style. display = "none": obj. style. display = "";
}
Is it a little too simple? Yes, it's that simple, but it's not over yet. Let's continue to look down; then add Level 3 and Level 4 sub-menus:
The Code is as follows:
1
1.1
1.1.1
1.1.1.1
1.1.1.2
1.1.2
1.2
1.3
The js Code still only has that line. so easy, but is it true? The answer is NONONO! When you click a level, the page jumps. This is what we want, but the menu on the left is changed to the original one, and the status I just clicked is not saved, what should we do? Because my colleague is using ASP, it seems that there is no view status, so do I use session to save it? It seems to work, but if you click a little faster, you will find that the menu is sometimes different several times, but the response is not enough or the session is lost. In the end, unfortunately, I found my name very interesting, level 1 is 1, level 2 is 1.1 Level 3 is 1.1.1, Level 4 is 1.1.1.1. What do you think? I think of a multi-level category query for database design !? It seems that the category in discuz is designed in this way. It also queries quickly, so I will give it a fast, just so happy.
The Code is as follows:
The Code is as follows:
1
>
1.1
>
1.1.1
>
1.1.1.1
1.1.1.2
1.1.2
1.2
1.3
2
3
I believe that this code is not much different from asp or asp.net. In fact, it can be done with pure js. But since it is used in asp, why should I write more JavaScript? Okay, the function is implemented. Everyone is okay. If you have different methods, please share them with us. Progress from learning...