下記の機能を作成しようとしています。jquery stars rating control
Iveには5つの画像があります。サーバー上では、各画像に表示する画像の色を決めます。サーバー上で計算されたレーティングが3の場合、最初の3つ星はyelloで、最後の2つはグレーです。
(jqueryを使用して)機能を達成したいと思います。ユーザーが星を飛ぶとき、この1つ前の色が赤に変わり(画像のURLが変更され)、次のすべての星は灰色になりますが、カーソルが星から離れると、その5つの星の状態は入力前と同じになります。
私はそれを希望として私は良いと本当に動作していない。このようなことを書きましたが、そのない:
var stars = {
initStars: function initStars() {
$('.starsHolder').hover(function() {
this.star1ImageUrl = $(this).children('.star').eq(0).attr('src');
this.star2ImageUrl = $(this).children('.star').eq(1).attr('src');
this.star3ImageUrl = $(this).children('.star').eq(2).attr('src');
this.star4ImageUrl = $(this).children('.star').eq(3).attr('src');
this.star5ImageUrl = $(this).children('.star').eq(4).attr('src');
$(this).children('.star').hover(function() { $(this).attr('src', '/star_red.png'); $(this).prevAll('.star').attr('src', '/star_red.png');}, function() { });
}, function(){
$(this).children('.star').eq(0).attr('src', this.star1ImageUrl);
$(this).children('.star').eq(1).attr('src', this.star2ImageUrl);
$(this).children('.star').eq(2).attr('src', this.star3ImageUrl);
$(this).children('.star').eq(3).attr('src', this.star4ImageUrl);
$(this).children('.star').eq(4).attr('src', this.star5ImageUrl);
$(this).children('.star').unbind();
})
}
};
星はASPです:私はsrc属性を変更する理由のImageButtonはthatsのが、それは問題をdoesntの。その
この1つはクールに見えると維持:http://rateit.codeplex.com/ –