Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="buttons">
- <a id="showall">All</a>
- <a class="showSingle" target="1">Morning</a>
- <a class="showSingle" target="2">APM</a>
- <a class="showSingle" target="3">Night</a>
- </div>
- <div id="div1" class="targetDiv">Lorum Ipsum1</div>
- <div id="div2" class="targetDiv">Lorum Ipsum2a</div>
- <div id="div2" class="targetDiv">Lorum Ipsum2b</div>
- <div id="div3" class="targetDiv">Lorum Ipsum3</div>
- <a class="showSingle" target="2">APM</a>
- <div id="div2" class="targetDiv">Lorum Ipsum2a</div>
- <div id="div2" class="targetDiv">Lorum Ipsum2b</div>
- jQuery(function(){
- jQuery('#showall').click(function(){
- jQuery('.targetDiv').show();
- });
- jQuery('.showSingle').click(function(){
- jQuery('.targetDiv').hide();
- jQuery('#div'+$(this).attr('target')).show();
- });
- });
- $(function(){
- $('#showall').click(function(){
- jQuery('.targetDiv').show();
- });
- $('.showSingle').click(function(){
- var self = $(this);
- $('.targetDiv').hide();
- $('.targetDiv[rel=div' + self.attr('target') +']').show();
- });
- });
- <div rel="div1" class="targetDiv">Lorum Ipsum1</div>
- <div rel="div2" class="targetDiv">Lorum Ipsum2a</div>
- <div rel="div2" class="targetDiv">Lorum Ipsum2b</div>
- <div rel="div3" class="targetDiv">Lorum Ipsum3</div>
- $('div[id="div2"]')
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Example</title>
- <style>
- div[class]{display:none;}
- </style>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $('.showSingle').click(function(){
- $('div[class]').hide()
- var id=$(this).attr('target')
- $('.div'+id).show()
- })
- $('#showall').click(function(){
- $('div[class]').show()
- })
- })
- </script>
- </head>
- <body>
- <div id="buttons">
- <a id="showall">All</a><br/>
- <a class="showSingle" target="1">Morning</a><br/>
- <a class="showSingle" target="2">APM</a><br/>
- <a class="showSingle" target="3">Night</a><br/>
- </div>
- <div class="div1">Lorum Ipsum1</div>
- <div class="div2">Lorum Ipsum2a</div>
- <div class="div2">Lorum Ipsum2b</div>
- <div class="div3">Lorum Ipsum3</div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement