Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <meta charset="UTF-8">
- <head>
- <link rel="stylesheet" href="style.css" />
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
- <script>
- var is_voted = false;
- var k = 1;
- var i = 1;
- $(document).ready(function(){
- $('.empty').hover(function(){
- if(is_voted == false){
- $(this).prevAll().andSelf().addClass('full');
- $(this).nextAll().removeClass('full');
- //$(this).nextAll)().addClass('empty');
- }
- });
- $('#poll').mouseleave(function(){
- if(is_voted == false){
- $('#poll').children('.full').removeClass('full');
- }
- });
- $('.empty').click(function() {
- var note = $(this).attr('id'); //récupère l'ID : 1 -2 - 4 -5
- for(k = 1;k<=parseInt(note);k++){
- $('#'+k).prevAll().andSelf().addClass('full');
- }
- if(is_voted == true){
- is_voted = false;
- for(i = 1; i<=5;i++){
- $('#'+i).removeClass('full');
- }
- }else{
- is_voted = true;
- }
- $('.note_hidden').val(note);
- });
- });
- </script>
- <title></title>
- </head>
- <body>
- <div id="poll">
- <span class="empty" id="1">1</span>
- <span class="empty" id="2">2</span>
- <span class="empty" id="3">3</span>
- <span class="empty" id="4">4</span>
- <span class="empty" id="5">4</span>
- <form method="post" action="">
- <input type="hidden" name="note_hidden" class="note_hidden" value="0" />
- <input type="textarea" id="comment" name="comment" class="comment" />
- <input type="submit" value='envoyer' />
- </form>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement