1 <!DOCTYPE HTML>2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title></title>6 <Script>7 //stores the index of the clicked picture.8 varimgindexclicked;9 varIMGs;Ten //the way to set up the picture. Parameter I: from 0 to I is yellow, then empty. One functionSetimgbyindex (i) { A for (varEMP= 0; EMP<=i; EMP++) { - imgs[emp].src= "Img/staryellow.png"; - } the for (varEMP=Number (i)+ 1; EMP<imgs.length; EMP++) { - imgs[emp].src= "Img/starempty.png"; - } - } + - //move the mouse up, according to this picture of index, set 5 pictures of SRC. + functionSetmouseover (i) { A return function () { at Setimgbyindex (i); - }; - } - - //When you click on a picture, the index of the image is stored. - functionSetclick (i) { in return function () { - imgindexclicked=i; to //alert ("Counting starting from 0 ... The first "+i+" was ordered. "); + }; - } the * //mouse away from this picture, according to save the clicked picture Number imgindexclicked, set 5 pictures of SRC. $ functionSetmouseleave () {Panax Notoginseng Setimgbyindex (imgindexclicked); - } the + onload= function () { A IMGs=document.getElementsByTagName ("img"); the for (varIinchIMGs) { + Imgs[i].onmouseover=Setmouseover (i); - Imgs[i].onclick=Setclick (i); $ Imgs[i].onmouseleave=Setmouseleave;//the method is given, not the invocation of the method. So Setmouseleave (); it's wrong. $ } - }; - </Script> the </Head> - <Body>Wuyi <imgsrc= "Img/staryellow.png" /> the <imgsrc= "Img/staryellow.png" /> - <imgsrc= "Img/staryellow.png" /> Wu <imgsrc= "Img/staryellow.png" /> - <imgsrc= "Img/staryellow.png" /> About </Body> $ </HTML>
JavaScript star ratings