title: Assign css class in jQuery based on razor C# list count
body: <p>I'm having a css menu for notifications. It's all in a div. Inside this div I have a link which, when hovered, shows the notifications in a menu like fashion. </p>
  
  <p>I want to change the background color of the div if there are notifications and remove the background color if the link has been hovered. I want to use the count property of a  C# razor variable named "templates" which stores the templates of the notifications to be showed in the menu.</p>
  
  <p>I want to do something like this in javascript/jquery</p>
  
  <pre><code>$(document).ready(function())
  {
    if(@templates.Count &gt; 0)
    {
      $('#notificationsMenuItem').addClass('notifNotSeen');
    }
  }
  
   function changeBackground() {
      var menu = $('#notificationsMenuItem');
  
      if(menu.hasClass('notifNotSeen'))
          menu.removeClass('notifNotSeen');
  }
  </code></pre>
  
  <p>Here is the div that contains the menu structure:</p>
  
  <pre><code>&lt;div id="notificationsMenuItem" class="divList"&gt;
     &lt;a href="#" style="font-weight: normal; padding: 0;"   onmousedown="changeBackground()"&gt;Notifications&lt;/a&gt;
  ........
  
  
   &lt;/div&gt;
  </code></pre>
  
  <p>Is this possible? What other ways to do this are there? </p>