Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <div class="heart btn pull-right click-heart peinto-heart-empty" data-is-clicked="false" data-sketch-id="someid"></div>
  2.  
  3. <div class="poop btn pull-right click-poop peinto-poop-empty" data-is-clicked="false" data-sketch-id="someid"></div>
  4.  
  5. <div class="voting-box">
  6. <button class="upvote" ... >Up!</button>
  7. <button class="downvote" ... >Down!</button>
  8. </div>
  9.  
  10. function onUpvoteClick(event) {
  11. var downvoteButton = $(event.target).parent().find('.downvote');
  12. // do something with the downvote button, eg:
  13. downvoteButton.css('color', 'red');
  14. }
  15.  
  16. Item 1
  17. <a class="vote" data-id="1" data-direction="up">Vote Up</a>
  18. <a class="vote" data-id="1" data-direction="down">Vote Down</a>
  19.  
  20. <br>
  21.  
  22. Item 2
  23. <a class="vote" data-id="2" data-direction="up">Vote Up</a>
  24. <a class="vote" data-id="2" data-direction="down">Vote Down</a>
  25.  
  26. $(function() {
  27. $('a.vote').click(function(e) {
  28. var id = $(this).data('id');
  29.  
  30. //save the vote (via ajax)
  31.  
  32. $('a.vote[data-id="' + id + '"]').removeClass('selected');
  33. $(this).addClass('selected');
  34. });
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement