JS background commonly used telescopic (folding) Menu code

Source: Internet
Author: User

 <style type= "Text/css"

*{margin:0;padding:0;} body{padding-top:10px;} div{width:150px;height:22px;margin-left:10px;overflow:hidden;font-size:12px;background: #FFF;} Div Div{clear:both;height:22px;margin:0;padding-left:25px;font-size:13px;line-height:22px;background: #CCC; Cursor:pointer;} Div ul Li{list-style:none;} a:link,a:visited{width:121px;height:20px;padding-left:29px;line-height:20px;color:# 000;text-decoration:none;display:block;} A:hover{background: #eee} &lt;/style&gt; HTML section &lt;div style= "Height:auto" &gt; &nbsp;&lt;div&gt; Menu One &lt;/div&gt; &nbsp;&lt;ul&gt; &nbsp; &lt;li&gt;&lt;a href= "#" &gt; Function one &lt;/a&gt;&lt;/li&gt; &nbsp; &lt;li&gt;&lt;a href= "#" &gt; Function II &lt;/a&gt;&lt;/li&gt; &nbsp;&lt;/ul&gt; &lt;/div&gt; &lt;div&gt; menu two &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href= "#" &gt; function &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href= "#" &gt; Function two &lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div &gt; Menu three &lt;/div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href= "#" &gt; Function one &lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href= "#" &gt; Function II &lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;div style= "Height:auto;color: #666; line-height:20px;cursor:default;" &gt; &nbsp;&lt;div style= "color: #000;" &gt; Version Information &lt;/div&gt; &nbsp; name: &lt;br/&gt; &nbsp; version: &lt;br/&gt; &nbsp; Core: &lt;br/&gt; &lt;/div&gt; &nbsp; &nbsp; &lt;s Cript type= "Text/javascript" &gt; Window.onload=function () {var div=document.getelementsbytagname ("div"); &nbsp;for ( i=0;i&lt;div.length-2;i++) {&nbsp; if (i%2!=0) {&nbsp; &nbsp; if (Div[i-1].getelementsbytagname ("ul"). Length&gt;0) { &nbsp; &nbsp;div[i].divid=i; &nbsp; &nbsp;div[i].onclick=function () {&nbsp; &nbsp; var div=document.getelementsbytagname ("div"); &nbsp; &nbsp; for ( j=0;j&lt;div.length-2;j++) {&nbsp; &nbsp; &nbsp; if (j%2==0&amp;&amp;j+1!=this.divid) {&nbsp; &nbsp; &nbsp; &nbsp; DIV[J ].style.height= "22px"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp; var div=this.offsetheight; &nbsp; &nbsp; VAR Div=this.parentnode; &nbsp; &nbsp; VAR divclass=div.offsetheight; &nbsp; &nbsp; if (divclass&lt;=div) {Div.style.height= "Auto";} Else{div.style.height= "22px";} &nbsp; &nbsp; &nbsp;} &nbsp; &nbsp;} &nbsp; &nbsp;} &nbsp;} &nbsp; &lt;/script&gt;&lt;/t D&gt; &nbsp;&lt;/tr&gt; &lt;/table&gt;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.