How can I set/store cookie when anchor clicked
- by Unaverage Guy
I am trying to use Cookie so that a default style OR a specific style is applied in reference to the anchor tag clicked, even when the browser is closed/reopen.
So if the user clicked the second link, close or refresh the browser and reopen, than the style should still be active, if it is their first time the default should apply.
This is 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: (Compliments of StackOverflow)
<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>