Star reviews JQ

Source: Internet
Author: User

HTML structure

<Divclass= "List_item">    <span>Product Packaging Satisfaction Degree:</span>    <bclass= "Stars1"></b></Div><Divclass= "List_item">    <span>Satisfaction of delivery Speed:</span>    <bclass= "Stars2"></b></Div><Divclass= "List_item">    <span>Express Speed Satisfaction:</span>    <bclass= "Stars3"></b></Div>

JS Call

    var stars1=New Stars ($ ('. Stars1 '));     var stars2=New Stars ($ ('. Stars2 '));     var stars3=New Stars ($ ('. Stars3 '));    Stars1.creates ();    Stars2.creates ();    Stars3.creates ();

JS Details

//Star ReviewsfunctionStars (ele) { This. element=Ele;  This. Temp=ele.css (' background-position ');} Stars.prototype={creates:function(){        var_this= This; $ (_this.element). MouseMove (function(event) {_this.fnmove (); }). Click (function(event) {_this.fndown (); }). MouseLeave (function(event) {_this.fnleave ();    }); }, Fnmove:function(e) {vare=e | |window.event; vardisx=e.pagex-$ ( This. Element). Offset (). Left; if(disx<18){            $( This. Element). css (' background-position ', ' -199px-390px '); }Else if(disx<36){            $( This. Element). css (' background-position ', ' -182px-390px '); }Else if(disx<54){            $( This. Element). css (' background-position ', ' -165px-390px '); }Else if(disx<62){            $( This. Element). css (' background-position ', ' -148px-390px '); }Else if(disx<84){            $( This. Element). css (' background-position ', ' -131px-390px '); }}, Fndown:function(e) {vare=e | |window.event; vardisx=e.pagex-$ ( This. Element). Offset (). Left; if(disx<18){            $( This. Element). css (' background-position ', ' -199px-390px '); }Else if(disx<36){            $( This. Element). css (' background-position ', ' -182px-390px '); }Else if(disx<54){            $( This. Element). css (' background-position ', ' -165px-390px '); }Else if(disx<62){            $( This. Element). css (' background-position ', ' -148px-390px '); }Else if(disx<84){            $( This. Element). css (' background-position ', ' -131px-390px '); }         This. temp=$ ( This. Element). css (' background-position '); }, Fnleave:function(){        $( This. Element). css (' background-position ', This. temp); }}

Just a simple star review effect

Star reviews JQ

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.