jquery五つ星好評事例

3419 ワード




    
          
    
    
    
        var aMsg = [
            "    |     ,          ,    ",
            "   |     ,        ,   ",
            "  |    ,          ",
            "  |    ,          ,      ",
            "    |     ,          ,    "
        ]
        $(function () {
            $("li").on("mouseenter",function () {
                index=$(this).index();
                $(this).addClass("on").prevAll().addClass("on");
                $(this).nextAll().removeClass("on");
                console.log(index);
                $("p").css({
                    "display":"block",
                    "left":(index+1)*24
                })
                $("p").html("<em><b>" + (index+1) + "</b>   " + aMsg[index].match(/(.+)\|/)[1] + "</em>" + aMsg[index].match(/\|(.+)/)[1]);
            })
            $("li").on("mouseleave",function () {
                $(this).removeClass("on").siblings().removeClass("on");
                $(".add").addClass("on").prevAll().addClass("on");
                $("p").css("display","none")
            })
            $("li").on("click",function () {
                $(this).addClass("add").siblings().removeClass("add");
                $("#span").html("<strong>" + (index+1) + "  </strong> (" + aMsg[index].match(/\|(.+)/)[1] + ")")
            })
        })