JavaScript star ratings

Source: Internet
Author: User

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

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.