Set cookie dynamic based on id

Set cookie dynamic based on id


I have an Array of items, comming from a data source. What I want to do is to change the background color of the outher div when the user clicks on it. I have and id that can be a number from 1 up to let's say 100. I cannot do this with CSS because of the page will be refreshed after a click so I would like to set a cookie for this. However I cannot figure out how to do this.

I use thie jquery.cookies.js

<div class="xxx" id="{@ID}">
<a class="yyy" href="example.aspx?Title=@Title">
      <div class="zzz">My dynamic data comes here ..</div>

I have tried with something like this.. but I know is not right. Any thoughts?

 //var x = (;
  $.cookie('MyCookie', 'RED');
var MyCookie = $.cookie('MyCookie');
 if (MyCookie == 'RED') {