I need help with datePicker

I need help with datePicker

Hi everybody ! 

I'm new on this forum, sorry if i'm not at the good place to post this.. and sorry for my english im french :)

So.. i need to developp à calendar with event associate on some day.. 

i make this with datePicker and look my calendar : 


i create some event ( 3 in total ) and the color on days 1, 2 and 3 are day with event ! and when i click on a day with an event, i display event info in specific div. All is ok, that work, BUT when i click on a day with element, my div with color for event disapear.. :/

Check my code :   
  1. (function($) {
  2.         $(document).ready(function() {

  3.             var events = [
  4.                 {
  5.                     Title: "Événement 1",
  6.                     Date: new Date("10/01/2016"),
  7.                     Lieu: "Paris",
  8.                     Extrait: "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",
  9.                     Type: "Régionaux",
  10.                     Day: "1"
  11.                 },
  12.                 {
  13.                     Title: "Événement 2",
  14.                     Date: new Date("10/02/2016"),
  15.                     Lieu: "Toulouse",
  16.                     Extrait: "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",
  17.                     Type: "Divers",
  18.                     Day: "2"
  19.                 },
  20.                 {
  21.                     Title: "Événement 3",
  22.                     Date: new Date("10/03/2016"),
  23.                     Lieu: "Marseille",
  24.                     Extrait: "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",
  25.                     Type: "Nationaux",
  26.                     Day: "3"
  27.                 }
  28.             ];

  29.             $("#cal_content").datepicker({
  30.                 dayNamesMin: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ],
  31.                 monthNames: [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ],
  32.                 nextText: "Suivant",
  33.                 prevText: "Précédent",
  34.                 beforeShowDay: function(date) {
  35.                     var result = [true, '', null];
  36.                     var matching = $.grep(events, function(event) {
  37.                         return event.Date.valueOf() === date.valueOf();
  38.                     });

  39.                     if (matching.length) {
  40.                         result = [true, 'highlight', null];
  41.                     }
  42.                     return result;
  43.                 },
  44.                 onSelect: function(dateText) {
  45.                     var date,
  46.                         selectedDate = new Date(dateText),
  47.                         i = 0,
  48.                         event = null;

  49.                     /* Determine if the user clicked an event: */
  50.                     while (i < events.length && !event) {
  51.                         date = events[i].Date;

  52.                         if (selectedDate.valueOf() === date.valueOf()) {
  53.                             //console.log('clicked');
  54.                             event = events[i];
  55.                         }else{
  56.                             //console.log('no clicked');
  57.                         }
  58.                         i++;
  59.                     }
  60.                     if (event) {
  61.                         /* If the event is defined, perform some action here; show a tooltip, navigate to a URL, etc. */
  62.                         //alert(event.Title);
  63.                         $('#cal_event_content').html(
  64.                             '<div class="event type_'+event.Type+'">'
  65.                                 +'<span class="title">'+event.Title+'</span>'
  66.                                 +'<span class="lieu">'+event.Lieu+'</span>'
  67.                                 +'<span class="content">'+event.Extrait+'</span>'
  68.                             +'</div>'
  69.                         );
  70.                     }
  71.                 }
  72.             });

  73.             $(".ui-datepicker-calendar .ui-state-default").each(function () {
  74.                 //you can get the year using below code.
  75.                 var year = $(".ui-datepicker-year").first().html();
  76.                 var nb;
  77.                 for (nb = 0; nb < events.length; ++nb) {
  78.                     if ($(".ui-datepicker-month").first().html() == "Octobre" && $(this).html() == events[nb].Day) {
  79.                         //add custome text to date cell
  80.                         //$(this).parent().attr('data-type',"Nationaux");
  81.                         var type = events[nb].Type;
  82.                         $(this).after('<div class="puce_color '+type+'"></div>');
  83.                     }
  84.                 }
  85.             });

  86.         });
  87.     })( jQuery );
On line 80, this is what i use to insert "puce_color" with good event type to add the small color on the good day.. 

But i don't know how to keep my "puce_color" after click a event day.. 

Can someone help me please ? Did am i on the good way ?

Thanks for help :)