I'm trying to use a cookie so that the default style or a specific style applies to the anchor anchor tag, even when the browser is closed / reopened. Therefore, if the user clicks the second link, close or refresh the browser and reopen what the style should be active if this is the first time that it should be applied by default. It's a little over my turf.
Here is the HTML:
<a id="default" href="#/">Default Style</a> <a id="style2" href="#/">Style 2</a> <a id="style3" href="#/">Style 3</a> <ol> <li><span>Hello World</span></li> </ol>
JQuery: (StackOverflow compliments)
<script type="text/javascript"> $('#default').on('click',function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('default'); }); $('#style2').click(function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('style2'); }); $('#style3').click(function(){ $('ol li span').removeClass(function() { return $(this).attr('class'); }).addClass('style3'); }); </script>
CSS
<style type="text/css"> .default{ color: #333; } .style2{ color: #999; } .style3{ color: #800; } </style>
source share