jquery code to achieve a simple five-star evaluation function!

Source: Internet
Author: User

Implementation: 1, the mouse moves to the third star, then 123 stars lighten, the latter two darken

2, the mouse click on a star, you can continue to choose, but after the stars will hold the position you click

<Scripttype= "Text/javascript">        //★        $(function () {            //because it is not good to get the coordinates of the clicked span, declare a variable to record the ID of the clicked span tag            varMark; $("*"). css ({margin:"0px", padding:"0px;" }); $("span"). css ({fontSize:"20px", Color:"Yellow"}). MouseOver (function () {                    $( This). Text ("★"). Prevall (). Text ("★"). End (). Nextall (). Text ("☆"). End (). Click (function() {Mark= $( This). attr ("ID");            })                }); $("Div"). css ({width:"100px", Height:"20px", border:"1px solid Black"}). mouseout (function () {                    //If you have content in Mark, let the number of stars change back to the location of your most recent click when the mouse leaves the div .                     if(Mark) {$ ("#" +mark). Text ("★"). Prevall (). Text ("★"). End (). Nextall (). Text ("☆"); }                     //Mark does not have a value, meaning that you do not click on any star, at this time, so that all the stars are Dim                     Else {                         $("span"). Text ("☆");        }                 });    }); </Script></Head><Body>    <DivID= "Div">        <spanID= "1">☆</span><spanID= "2">☆</span><spanID= "3">☆</span><spanID= "4">☆</span><spanID= "5">☆</span>    </Div> </Body>

jquery code to achieve a simple five-star evaluation function!

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.