Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use:</p> <pre><code>$('.red').removeClass('red').addClass('blue'); </code></pre> <p><a href="http://jsbin.com/ugufi" rel="nofollow noreferrer">Here's the full working code</a>:</p> <pre><code>$(function() { $("a").click(function() { var color = $(this).text(); $("body").removeClass().addClass(color); return false; }); }); </code></pre> <p>And now for the cookie part</p> <pre><code>$(function() { $("a").click(function() { var color = $(this).text(); $("body").removeClass().addClass(color); createCookie("color",color); return false; }); if (readCookie("color") != null) { $("body").removeClass().addClass(readCookie("color")); } else { $("body").removeClass().addClass("red"); } }); function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i=0;i &lt; ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } </code></pre> <p><a href="http://jsbin.com/usucu" rel="nofollow noreferrer">Working example here</a>. A thank you to <a href="http://www.quirksmode.org/js/cookies.html" rel="nofollow noreferrer">QuirksMode</a> for the pre-made cookie code (cookie-cutter cookie code?)</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.
    3. 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