Copy codeThe Code is as follows:
<Div> <a onclick = "news_pro ('1. 1')"> 1 </a> </div>
<Div id = "1.1" type = "parmname" text = "parmname">
<Div> <a onclick = "news_pro ('1. 100')"> 1.1 </a> </div>
</Div>
This shows two categories. Click the parent-Level Display (hidden) sub-level menu, and the JS Code will be in the same sentence:
Copy codeThe 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:
Copy codeThe Code is as follows:
<Div> <a onclick = "news_pro ('1. 1')"> 1 </a> </div>
<Div id = "1.1" type = "parmname" text = "parmname">
<Div> <a onclick = "news_pro ('1. 100')"> 1.1 </a> </div>
<Div id = "1.1.1">
<Div> <A onclick = "news_pro ('1. 1.1.1 ')"> 1.1.1 </a> </div>
<Div id = "1.1.1.1">
<Div> 1.1.1.1 </div>
<Div> 1.1.1.2 </div>
</Div>
<Div> 1.1.2 </div>
</Div>
& Lt; div & gt; 1.2 & lt;/div & gt;
& Lt; div & gt; 1.3 & lt;/div & gt;
</Div>
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:
Copy codeThe Code is as follows:
<Div> <a onclick = "news_pro ('1. 1')" href = "? Id = 1.1 "> 1 </a> </div>
& Lt; div id = "1.1" & lt; % If InStr (request. querystring ("id"), "1.1") = 0 Then response. write style = 'display: none; '%>
<Div> <a onclick = "news_pro ('1. 1.1 ')" href = "? Id = 1.1.1 "> 1.1 </a> </div>
<Div id = "1.1.1" style = "display: none;" <% If InStr (request. querystring ("id"), "1.1.1") = 0 Then response. write style = 'display: none; '%>
<Div> <A onclick = "news_pro ('1. 1.1.1 ')" href = "? Id = 1.1.1.1 "> 1.1.1 </a> </div>
<Div id = "1.1.1.1" <% If InStr (request. querystring ("id"), "1.1.1.1") = 0 Then response. write style = 'display: none; '%>
<Div> 1.1.1.1 </div>
<Div> 1.1.1.2 </div>
</Div>
<Div> 1.1.2 </div>
</Div>
& Lt; div & gt; 1.2 & lt;/div & gt;
& Lt; div & gt; 1.3 & lt;/div & gt;
</Div>
<Div> <a> 2 </a> </div>
<Div> <a> 3 </a> </div>
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...