Guest User

Untitled

a guest
Jan 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <!-- ... code .. -->
  2.  
  3. var id = 0;
  4.  
  5. data.forEach(function(item, i) {
  6. id = id+1;
  7.  
  8. $( ".button-" + id ).click(function() {
  9. $( ".button-" + id ).toggle();
  10.  
  11. });
  12.  
  13. <!-- ... code .. -->
  14.  
  15. $( ".button-" + id ).click(function() {
  16. $( ".button-" + id ).toggle();
  17.  
  18. <a href="" class="likebutton-1"><i class="material-icons">favorite</i></a>
  19. <a href="" class="likebutton-1" style="display:none;"><i class="material-icons">favorite_border</i></a>
  20.  
  21. <div class="likes-1">99 likes</div>
  22. <div class="likes-1" style="display:none;">100 likes</div>
  23.  
  24. $( ".likebutton-1" ).click(function() {
  25. $( ".likebutton-1" ).toggle();
  26. $( ".likes-1" ).toggle();
  27. });
  28.  
  29. $("[class*=button-]").click(function(){
  30. $(this).toggle()
  31. })
  32.  
  33. $("[class*='button-']").click(function(){
  34. $(this).toggle();
  35. });
  36.  
  37. var id = 0;
  38.  
  39. data.forEach(function(item, i) {
  40. id = id+1;
  41. var bindEvents = function theOutterFunction() {
  42. return function() {
  43. $( ".button-" + id ).click(function() {
  44. $( ".button-" + id ).toggle();
  45. }
  46. }();
  47. bindEvents();
  48. });
  49.  
  50. <div>
  51. <h1>Dynamic buttons added below</h1>
  52. <ul id="divDyno"><!-- Buttons will be added here --></ul>
  53. </div>
  54.  
  55. $('#ulDyno').on('click', '[class*=button-]', function(e) {
  56. $(this).toggle();
  57. })
Advertisement
Add Comment
Please, Sign In to add comment