Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Acutally there is nothing special, you have only three tabs ( list, grid, full ). First, i recommend to you to follow the mark-up below : </p> <pre><code> &lt;ul class="tabs js-view-mode"&gt; &lt;li&gt;&lt;a href="#list"&gt;List&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#grid"&gt;Grid&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#full"&gt;Full&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;section id="viewMode"&gt; &lt;div id="list"&gt;here is list mode content&lt;/div&gt; &lt;div id="grid"&gt;here is grid mode content&lt;/div&gt; &lt;div id="full"&gt;here is full mode content&lt;/div&gt; &lt;/section&gt; </code></pre> <p>As you can see, on tabs, inside <code>&lt;a href=""&gt;</code> class i put the id's for what we want to show. This is safe and easy because the script will not confuse what he has to show. </p> <p>Also in html you must load jquery library and jquery-cookie ( you can avoid loading this plugin following the documentation for <a href="http://www.w3schools.com/js/js_cookies.asp" rel="nofollow">javascript-cookies</a> ). Better load them before <code>&lt;/body&gt;</code> tag to get a faster loading time for page. </p> <p>The jQuery code for what you want looks like :</p> <pre><code>$(document).ready(function(){ var wrap = $('#viewMode'), viewMode = $.cookie( 'view-mode' ); wrap.children().hide(); $('.js-view-mode').on( 'click', 'a',function( e ){ e.preventDefault(); var t = $(this), type = t.attr('href'); $(type).fadeIn() .siblings().fadeOut(); viewMode = $.cookie( 'view-mode', type ); }); if ( viewMode ) { $('.js-view-mode a[href='+ viewMode +']').trigger('click'); } else { $('.js-view-mode li:first a').trigger( 'click' ); } }); </code></pre> <p>You can see a live test <a href="http://fiddle.jshell.net/9ae3T/" rel="nofollow">here</a></p> <p><strong>Edit :</strong> <a href="http://fiddle.jshell.net/stefanz/9ae3T/21/" rel="nofollow">JS Fiddle v2</a> ( add active clas + delay fadeIn/Out + return on clicking active item )</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload