<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> <Title> close and expand through the overflow control list </title> <Style type = "text/css"> Div dl { Margin: 0; Padding: 0; Font-size: 14px; } # DivMain { Width: 500px; Background-color: # 22477A; Margin: 0 auto; Margin-top: 30px; } Dl { Width: 200px; Background: # A6BCE5; Height: 14px;/* the same height as the font size */ Overflow: hidden;/* default overflow hidden */ } Dt { Cursor: pointer;/* set the hand cursor */ Font-weight: bold; Color: Green; } . Open { Height: pixel PX; Overflow: visible; } . Close { Height: 14px;/* the same height as the font size */ Overflow: hidden; } </Style> <Script type = "text/javascript"> Function DisplayList (){ Var dtNode = window. event. srcElement; Var dlNode = dtNode. parentNode; Var dlNodes = document. getElementsByTagName ("dl "); For (var I = 0; I <dlNodes. length; I ++ ){ If (dlNodes [I] = dlNode) {// you can check whether the selected dl is used. If (dlNodes [I]. className = "open "){ DlNodes [I]. className = "close "; } Else { DlNodes [I]. className = "open "; } } Else { DlNodes [I]. className = "close "; } } } </Script> </Head> <Body> <Div id = "divMain"> <Dl> <Dt onclick = "DisplayList ()"> Star List 1 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> <Br/> <Dl> <Dt onclick = "DisplayList ()"> Star List 2 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> <Br/> <Dl> <Dt onclick = "DisplayList ()"> Star list 3 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> <Br/> <Dl> <Dt onclick = "DisplayList ()"> Star list 4 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> <Br/> <Dl> <Dt onclick = "DisplayList ()"> Star List 5 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> <Br/> <Dl> <Dt onclick = "DisplayList ()"> Star list 6 </Dt> <Dd> Ronaldo </dd> <Dd> Beckham </dd> <Dd> Zidane </dd> <Dd> Neymar </dd> <Dd> Pattaya </dd> <Dd> Messi </dd> </Dl> </Div> </Body> </Html> |