Last active
August 29, 2015 14:13
-
-
Save bogomolov-dev/55eeb15acbb36e5126db to your computer and use it in GitHub Desktop.
jQuery - Sternchen Bewertungssystem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="rating"> | |
<li class="star_off"><a title="Ich vergebe dem Rezept 1 Punkt" href="?star=1">Ich vergebe dem Rezept 1 Punkt</a></li> | |
<li class="star_off"><a title="Ich vergebe dem Rezept 2 Punkte" href="?star=2">Ich vergebe dem Rezept 2 Punkte</a></li> | |
<li class="star_off"><a title="Ich vergebe dem Rezept 3 Punkte" href="?star=3">Ich vergebe dem Rezept 3 Punkte</a></li> | |
<li class="star_off"><a title="Ich vergebe dem Rezept 4 Punkte" href="?star=4">Ich vergebe dem Rezept 4 Punkte</a></li> | |
<li class="star_off"><a title="Ich vergebe dem Rezept 5 Punkte" href="?star=5">Ich vergebe dem Rezept 5 Punkte</a></li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.star_off').mouseover(function(){ | |
$(this).removeClass('star_off').addClass('star_on'); | |
$(this).prevAll('.star_off').removeClass('star_off').addClass('star_on'); | |
$(this).nextAll('.star_on').removeClass('star_on').addClass('star_off'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#rating').hover(function(){ | |
// Vorherige Sterne aktivieren und nachkommende ausblenden | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('#rating').hover(function(){ | |
// Vorherige Sterne aktivieren und nachkommende ausblenden | |
}, function() { | |
$('.star_on').removeClass('star_on').addClass('star_off'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$('#rating').hover(function(){ | |
$('.star_off').mouseover(function(){ | |
$(this).removeClass('star_off').addClass('star_on'); | |
$(this).prevAll('.star_off').removeClass('star_off').addClass('star_on'); | |
$(this).nextAll('.star_on').removeClass('star_on').addClass('star_off'); | |
}); | |
}, function() { | |
$('.star_on').removeClass('star_on').addClass('star_off'); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gewählten Wert in einer Variable speichern | |
$('#rating a').click(function(e) { | |
e.preventDefault(); | |
// Über DOM | |
var rating = $(this).parent().index() + 1; | |
// Über Parameter | |
var rating = $(this).attr('href').split('=')[1] | |
// Mache etwas mit der Zahl | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rating li { | |
float:left; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rating li.star_off { | |
background:url('lib/images/star_off_48.png') no-repeat left top; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rating li.star_on { | |
background:url('lib/images/star_48.png') no-repeat left top; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#rating a { | |
display:block; | |
font-size:0px; | |
width:48px; | |
height:48px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment