How to implement simple folding and expanding menu in js
This article mainly introduces the method of implementing simple folding and unfolding menus in js, and involves the related techniques of javascript dynamic operation of page element transformation. It has certain reference value. Friends in need can refer to it. The details are as follows:
What we introduce here is a menu navigation bar that can be folded and expanded. It was written in a very old time. CSS has not been beautified. If you want to use it, you can beautify it yourself.
A screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/ js/2015/js-simple-hidden-show-menu-codes/
The specific code is as follows:
<html> <script> function show(c_Str) {if(document.all(c_Str).style.display=='none') {document.all(c_Str).style.display='block';} else{document.all(c_Str).style.display='none';}} function high(){ if (event.srcElement.className=="k"){ event.srcElement.style.background="336699" event.srcElement.style.color="white" } } function low(){ if (event.srcElement.className=="k"){ event.srcElement.style.background="99CCFF" event.srcElement.style.color="" } } </script> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>导航栏</title> <style> td { cursor: hand; font-family: Tahoma; background-color: #336699; color: #99CCFF; font-size: 10pt } li{ color: #FF0000; font-family: Tahoma; background-color: #99CCFF; font-size: 9pt} .up{ background-color: #3A6EA5; border-left: 1 solid #A6C1DF;border-right: 1 solid #002200; border-top: 1 solid #A6C1DF; border-bottom: 1 solid #002200 } </style> </head> <body topmargin="0" leftmargin="5"> <p align="left"> <table border="0" width="48" cellspacing="0" cellpadding="0"> <tr> <td><p class=up onclick=show("a0")>+01-10</p><p onmouseover=high() onmouseout=low() id=a0 style="display:none"> <li class=k>01</li> <li class=k>02</li> <li class=k>03</li> <li class=k>04</li> <li class=k>04</li> <li class=k>05</li> <li class=k>06</li> <li class=k>07</li> <li class=k>08</li> <li class=k>09</li> <li class=k>10</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a1")>+11-20</p><p onmouseover=high() onmouseout=low() id=a1 style="display:none"> <li class=k>11</li> <li class=k>12</li> <li class=k>13</li> <li class=k>14</li> <li class=k>15</li> <li class=k>16</li> <li class=k>17</li> <li class=k>18</li> <li class=k>19</li> <li class=k>20</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a2")>+21-30</p><p onmouseover=high() onmouseout=low() id=a2 style="display:none"> <li class=k>21</li> <li class=k>22</li> <li class=k>23</li> <li class=k>24</li> <li class=k>25</li> <li class=k>26</li> <li class=k>27</li> <li class=k>28</li> <li class=k>29</li> <li class=k>30</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a3")>+31-40</p><p onmouseover=high() onmouseout=low() id=a3 style="display:none"> <li class=k>31</li> <li class=k>32</li> <li class=k>33</li> <li class=k>34</li> <li class=k>35</li> <li class=k>36</li> <li class=k>37</li> <li class=k>38</li> <li class=k>39</li> <li class=k>40</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a4")>+41-50</p><p onmouseover=high() onmouseout=low() id=a4 style="display:none"> <li class=k>41</li> <li class=k>42</li> <li class=k>43</li> <li class=k>44</li> <li class=k>45</li> <li class=k>46</li> <li class=k>47</li> <li class=k>48</li> <li class=k>49</li> <li class=k>50</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a5")>+51-60</p><p onmouseover=high() onmouseout=low() id=a5 style="display:none"> <li class=k>51</li> <li class=k>52</li> <li class=k>53</li> <li class=k>54</li> <li class=k>55</li> <li class=k>56</li> <li class=k>57</li> <li class=k>58</li> <li class=k>59</li> <li class=k>60</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a7")>+61-70</p><p onmouseover=high() onmouseout=low() id=a7 style="display:none"> <li class=k>61</li> <li class=k>62</li> <li class=k>63</li> <li class=k>64</li> <li class=k>65</li> <li class=k>66</li> <li class=k>67</li> <li class=k>68</li> <li class=k>69</li> <li class=k>70</li> </p></td> </tr> <tr> <td><p class=up onclick=show("a8")>+71-80</p><p onmouseover=high() onmouseout=low() id=a8 style="display:none"> <li class=k>71</li> <li class=k>72</li> <li class=k>73</li> <li class=k>74</li> <li class=k>75</li> <li class=k>76</li> <li class=k>77</li> <li class=k>78</li> <li class=k>79</li> <li class=k>80</li> </p></td> </tr> </table> </p> </body> </html>
The above is the entire content of this chapter. For more related tutorials, please Visit JavaScript Video Tutorial!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Face detection and recognition technology is already a relatively mature and widely used technology. Currently, the most widely used Internet application language is JS. Implementing face detection and recognition on the Web front-end has advantages and disadvantages compared to back-end face recognition. Advantages include reducing network interaction and real-time recognition, which greatly shortens user waiting time and improves user experience; disadvantages include: being limited by model size, the accuracy is also limited. How to use js to implement face detection on the web? In order to implement face recognition on the Web, you need to be familiar with related programming languages and technologies, such as JavaScript, HTML, CSS, WebRTC, etc. At the same time, you also need to master relevant computer vision and artificial intelligence technologies. It is worth noting that due to the design of the Web side

According to news on June 25, the source ytechb published a blog post yesterday (June 24), sharing a rendering of the Google Pixel 9 Pro Fold mobile phone case, once again showing the design of the back of this folding screen. According to previous news, Google will release the Pixel 9 series of mobile phones in October this year. In addition to the three phones in the Pixel 9 series, Pixel Fold will also be included in the Pixel 9 series and will be officially named Pixel 9 Pro Fold. The phone case exposed this time comes from accessory manufacturer Torro. The company's UK and US online stores have listed the product phone case and disclosed the design and display size of the phone. The page shows a large number of Pixel 9 Pro Fold phone case renderings

Essential tools for stock analysis: Learn the steps to draw candle charts in PHP and JS. Specific code examples are required. With the rapid development of the Internet and technology, stock trading has become one of the important ways for many investors. Stock analysis is an important part of investor decision-making, and candle charts are widely used in technical analysis. Learning how to draw candle charts using PHP and JS will provide investors with more intuitive information to help them make better decisions. A candlestick chart is a technical chart that displays stock prices in the form of candlesticks. It shows the stock price

According to news on June 21, foreign media recently released model photos of Samsung Galaxy Z Flip 6 on the Internet. According to the picture, it can be understood that the borders of Samsung Galaxy Z Flip 6 will be further narrowed, which means that the width of the phone may be reduced in the folded state, and it will also provide a more comfortable grip and portability. Moreover, compared with the previous generation ZFlip5, the model of Galaxy ZFlip6 is more square and the camera module on the back is more prominent. It is expected to use a new camera sensor. However, from the front, the creases of the phone are still relatively obvious, but considering that the leaked model is a model phone, there may be some differences with the real phone, so it is for reference only. In terms of performance configuration, Galaxy

How to use PHP and JS to create a stock candle chart. A stock candle chart is a common technical analysis graphic in the stock market. It helps investors understand stocks more intuitively by drawing data such as the opening price, closing price, highest price and lowest price of the stock. price fluctuations. This article will teach you how to create stock candle charts using PHP and JS, with specific code examples. 1. Preparation Before starting, we need to prepare the following environment: 1. A server running PHP 2. A browser that supports HTML5 and Canvas 3

According to news on August 23, Samsung is about to launch a new folding mobile phone W25, which is expected to be unveiled at the end of September. It will make corresponding improvements in the under-screen front camera and body thickness. According to reports, Samsung W25, codenamed Q6A, will be equipped with a 5-megapixel under-screen camera, which is an improvement over the 4-megapixel camera of the Galaxy Z Fold series. In addition, the W25’s external-screen front camera and ultra-wide-angle camera are expected to be 10 million and 12 million pixels respectively. In terms of design, the W25 is about 10 mm thick in the folded state, which is about 2 mm thinner than the standard Galaxy Z Fold 6. In terms of screen, the W25 has an external screen of 6.5 inches and an internal screen of 8 inches, while the Galaxy Z Fold6 has an external screen of 6.3 inches and an internal screen of 8 inches.

What we are discussing today is not what a certain product is like, but returning to the topic of "folding screen" itself and exploring the "rationality" of folding screen mobile phones. First, let’s take a look at the market performance of folding screen mobile phones. According to IDC’s latest data report, China’s folding screen mobile phone market will ship approximately 7.007 million units in 2023, a year-on-year increase of 114.5%. Among them, China's foldable screen mobile phone market shipped approximately 2.771 million units in the fourth quarter of 2023, a year-on-year increase of 149.6%. The data does look good, and the growth is also very strong. However, compared with the approximately 270 million smartphone shipments in the Chinese market in 2023, this data is really not enough. In general

According to news on February 24, IDC recently released a market research report, predicting that global smartphone shipments will reach 1.2 billion units in 2024, a year-on-year increase of 2.8%, and will then maintain low single-digit growth by 2028. IDC believes that overall shipments in 2024 will still be below pre-pandemic levels, but the global smartphone market has bottomed out and is beginning to show an upward trend in recovery. IDC believes that the two key factors driving the overall market recovery are the equipment refresh cycle and the growth of demand in emerging markets. There are also two main driving forces. IDC estimates that folding screen mobile phone shipments will reach 25 million units in 2024, a year-on-year increase of 37%; the other is that artificial intelligence (AI) has quickly become a part of the discussion on smartphones, triggering
