Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  4. </head>
  5.  
  6. <body>
  7. <a onclick="paid(123);" class="no" id="123"></a>
  8. <a onclick="paid(124);" class="yes" id="124"></a>
  9. <a onclick="paid(125);" class="no" id="125"></a>
  10. </body>
  11. </html>
  12.  
  13. <script type="text/javascript">
  14. function paid(currentId) {
  15.  
  16. if (document.getElementById(currentId).hasClass("no")) {
  17. document.getElementById(currentId).removeClass( 'no' );
  18. document.getElementById(currentId).addClass( 'yes' );
  19. }
  20.  
  21. else if (document.getElementById(currentId).hasClass("yes")) {
  22. document.getElementById(currentId).removeClass( 'yes' );
  23. document.getElementById(currentId).addClass( 'no' );
  24. }
  25.  
  26. }
  27. </script>
  28.  
  29. function paid(currentId) {
  30.  
  31. // Select the element using jQuery
  32. var $elem = $("#"+currentId);
  33.  
  34. if ($elem.hasClass("no")) {
  35. $elem.removeClass( 'no' );
  36. $elem.addClass( 'yes' );
  37. }
  38.  
  39. else if ($elem.hasClass("yes")) {
  40. $elem.removeClass( 'yes' );
  41. $elem.addClass( 'no' );
  42. }
  43.  
  44. }
  45.  
  46. $("a").on("click", function() {
  47. if ($(this).hasClass("no")) {
  48. $(this).removeClass( 'no' );
  49. $(this).addClass( 'yes' );
  50. }
  51.  
  52. else if ($(this).hasClass("yes")) {
  53. $(this).removeClass( 'yes' );
  54. $(this).addClass( 'no' );
  55. }
  56. });
  57.  
  58. jQuery(document).ready(function(){
  59. jQuery('a').click(function(){
  60. jQuery(this).toggleClass('yes');
  61. jQuery(this).toggleClass('no');
  62. })
  63. })
  64.  
  65. <a onclick="paid(this);" class="no" id="123">Link1</a>
  66. <a onclick="paid(this);" class="yes" id="124">Link1</a>
  67. <a onclick="paid(this);" class="no" id="125">Link1</a>
  68.  
  69. function paid(current) {
  70. if(current.className == "no") {
  71. current.className = 'yes';
  72. } else if(current.className == "yes") {
  73. current.className = 'no';
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement