Advertisement
Guest User

Untitled

a guest
Apr 25th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. <div class="buttons">
  2. <a id="showall">All</a>
  3. <a class="showSingle" target="1">Morning</a>
  4. <a class="showSingle" target="2">APM</a>
  5. <a class="showSingle" target="3">Night</a>
  6. </div>
  7.  
  8. <div id="div1" class="targetDiv">Lorum Ipsum1</div>
  9. <div id="div2" class="targetDiv">Lorum Ipsum2a</div>
  10. <div id="div2" class="targetDiv">Lorum Ipsum2b</div>
  11. <div id="div3" class="targetDiv">Lorum Ipsum3</div>
  12.  
  13. <a class="showSingle" target="2">APM</a>
  14.  
  15. <div id="div2" class="targetDiv">Lorum Ipsum2a</div>
  16. <div id="div2" class="targetDiv">Lorum Ipsum2b</div>
  17.  
  18. jQuery(function(){
  19. jQuery('#showall').click(function(){
  20. jQuery('.targetDiv').show();
  21. });
  22. jQuery('.showSingle').click(function(){
  23. jQuery('.targetDiv').hide();
  24. jQuery('#div'+$(this).attr('target')).show();
  25. });
  26. });
  27.  
  28. $(function(){
  29. $('#showall').click(function(){
  30. jQuery('.targetDiv').show();
  31. });
  32. $('.showSingle').click(function(){
  33. var self = $(this);
  34. $('.targetDiv').hide();
  35. $('.targetDiv[rel=div' + self.attr('target') +']').show();
  36. });
  37. });
  38.  
  39. <div rel="div1" class="targetDiv">Lorum Ipsum1</div>
  40. <div rel="div2" class="targetDiv">Lorum Ipsum2a</div>
  41. <div rel="div2" class="targetDiv">Lorum Ipsum2b</div>
  42. <div rel="div3" class="targetDiv">Lorum Ipsum3</div>
  43.  
  44. $('div[id="div2"]')
  45.  
  46. <!DOCTYPE HTML>
  47. <html>
  48. <head>
  49. <title>Example</title>
  50. <style>
  51. div[class]{display:none;}
  52. </style>
  53. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  54. <script type="text/javascript">
  55. $(document).ready(function(){
  56. $('.showSingle').click(function(){
  57. $('div[class]').hide()
  58. var id=$(this).attr('target')
  59. $('.div'+id).show()
  60. })
  61. $('#showall').click(function(){
  62. $('div[class]').show()
  63. })
  64. })
  65. </script>
  66. </head>
  67. <body>
  68.  
  69. <div id="buttons">
  70. <a id="showall">All</a><br/>
  71. <a class="showSingle" target="1">Morning</a><br/>
  72. <a class="showSingle" target="2">APM</a><br/>
  73. <a class="showSingle" target="3">Night</a><br/>
  74. </div>
  75.  
  76. <div class="div1">Lorum Ipsum1</div>
  77. <div class="div2">Lorum Ipsum2a</div>
  78. <div class="div2">Lorum Ipsum2b</div>
  79. <div class="div3">Lorum Ipsum3</div>
  80. </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement