JS cookies for styles

jonathan9797

New Member
Ok so I am new to the cookie business, and I still have yet to try the jQuery cookies. I have this code\[code\]$(function() { $('#left').before('<div id="left_widg"><button>Close</button></span>'); $('#right').before('<div id="right_widg"><button>Close</button></span>');$('#left_widg button').on('click',function() { var _checkme = $('#left').css('display'); var oriWidth = 180;if(_checkme === "block") { $('#left').animate({width:'-='+ oriWidth +'px'},500,function() { $(this).hide(); $('#left_widg button').html('Open');}); } else { $('#left').show(); $('#left').animate({width:'+='+ oriWidth +'px'},500,function() { $('#left_widg button').html('Close'); }); }});\[/code\]I want cookies to play a role in here, so when the close the LEFT it will stay closed until opened again/cookies are deleted. Can someone explain to me how to set the cookie, retrieve the cookie, and if cookie exists set the display accordingly. Also I'd need to make it so if they are playing with the toggler the cookie is deleted and set depending. I would need a cookie to exist only if they close it, and if that cookie exist to make sure the LEFT is closed (display:none). I am knew, and better are examining a code, so I offered this script as it is the easiest to me for someone to help write a COOKIEs code. No I am not looking for an easy way out, I just really have never used cookies and need a more hands on approach. I will need cookies for a lot more codes which are more advanced so like I said this is the easiest and quickest for example purposes.Thanks to whomever helps
 
Top