<! Doctype html> <Html> <Head> <Meta charset = "gbk"> <Title> switch </title> <Style> . Wrapper {width: 300px; margin: 10px auto; font: 14px/1.5 arial ;} /* Tab */ # Star {overflow: hidden ;} # Star li { Float: left; Width: 20px; Height: 20px; Margin: 2px; Display: inline; Color: #999; Font: bold 18px arial; Cursor: pointer } # Star. act { Color: # c00 } # Star_word { Width: 80px; Height: 30px; Line-height: 30px; Border: 1px solid # ccc; Margin: 10px; Text-align: center; Display: none } </Style> <Script> Window. onload = function (){ Var star = document. getElementById ("star "); Var star_li = star. getElementsByTagName ("li "); Var star_word = document. getElementById ("star_word "); Var result = document. getElementById ("result "); Var I = 0; Var j = 0; Var len = star_li.length; Var word = ['bad', 'bad', 'two', "good", "good"] For (I = 0; I <len; I ++ ){ Star_li [I]. index = I; Star_li [I]. onmouseover = function (){ Star_word.style.display = "block "; Star_word.innerHTML = word [this. index]; For (I = 0; I <= this. index; I ++ ){ Star_li [I]. className = "act "; } } Star_li [I]. onmouseout = function (){ Star_word.style.display = "none "; For (I = 0; I <len; I ++ ){ Star_li [I]. className = ""; } } Star_li [I]. onclick = function (){ Result. innerHTML = (this. index + 1) + "points "; } } } </Script> </Head> <Body> <Div class = "wrapper"> Score result <Span id = "result"> </span> <Ul id = "star"> <Li>★</Li> <Li>★</Li> <Li>★</Li> <Li>★</Li> <Li>★</Li> </Ul> <Div id = "star_word"> General </div> </Div> </Body> </Html> |