The category appears twice. Click the parent to display (hide) the child menu, JS code Just one sentence:
Isn’t it a bit too simple? Yes, it’s that simple, but it’s not over yet. Let’s continue reading; then add third-level and fourth-level submenus:
1.1.1.1
1.1.1.2< ;/div>
1.1.2
1.2
1.3
The js code still only has that line, so easy, but is it really over? The answer is NONONO! When you click on one of the levels, the page jumps, which is what we want, but the menu on the left changes to its original appearance, and the state I just clicked is not saved. So what should I do? Because my colleague wants to use it in ASP, it seems that there is no such thing as view state, so should I use session to save it? It seems to work, but if you click faster, you will find that the menu sometimes changes several times, and you can't react at all or the session is lost. Finally, I accidentally found that my naming is very interesting. The first level is 1. The second level is 1.1, the third level is 1.1.1, and the fourth level is 1.1.1.1. What comes to mind? Think of database design with multi-level category queries! ? It seems that the categories in discuz are designed this way. It is also very fast to query, so I will also do a quick query for it. Once I have an idea, I am so happy.
The code is as follows, using the url value transfer method:
>
>
< div> 1.1.1.1
1.1.1.2
1.2
1.3
I believe this code does not manage asp or There is not much difference in ASP.NET. In fact, it can also be done with pure JS. But since it is used in ASP, why do you need to write more JS? Ok, the function is implemented. Everyone is OK. If you have a different method, please post it and share it with everyone. Progress from learning. . .