| <! 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> dynamically control the li Team list </title> <Script type = "text/javascript"> Function iniEvent (){ Var ul = document. getElementById ("football "); Var lis = ul. getElementsByTagName ("li "); For (var I = 0; I <lis. length; I ++ ){ // Move the cursor over the event Lis [I]. onmouseover = function (){ Var ul = document. getElementById ("football "); Var lis = ul. getElementsByTagName ("li "); For (var I = 0; I <lis. length; I ++ ){ Var li = lis [I]; If (li = this ){ Li. style. background = "red "; } Else { Li. style. background = "gray "; } } } // Click the event Lis [I]. onclick = function (){ Var ul = document. getElementById ("football "); Var lis = ul. getElementsByTagName ("li "); For (var I = 0; I <lis. length; I ++ ){ Var li = lis [I]; If (li = this ){ Li. style. fontSize = 30; } Else { Li. style. fontSize = 16; } } } } } </Script> </Head> <Body onload = "iniEvent ()"> <! -- Function Description 1. The lines that move the mouse over become red. 2. Click the row to increase the font size. --> <Ul style = "width: 200px" id = "football"> <Li> Real Madrid </li> <Li> Manchester United </li> <Li> Chelsea </li> <Li> Barcelona </li> <Li> AC Milan </li> <Li> Milan </li> </Ul> </Body> </Html> |