title: jquery recently added highlighted css can not be remove after alert generate
body: <p><a href="http://jsfiddle.net/Cyjye/" rel="nofollow noreferrer">http://jsfiddle.net/Cyjye/</a>
  I m new to jquery. I have made html table shown in jsfiddle.Firstly selection be made from second row second cell in my html table selection be made from first row second cell. I have allot time to patient not more than 30 minutes. if user selects more than 30 minutes it gives alert "Time slot not more than 30 minutes". alert works correctly but its added css is not removed after alert. and whenever I mouse up after alert .cell is highlighted with css. I don't want to do like that if alert generate then recently added css to cell is removed and whenever I mouseup after alert then no cell be highlighted with css. I tried lot but not getting correct way.
  when I highlight 30 minute time and click on select patient button(below to html table there is select patient(patient getting from textbox)button) then highlight css is removed.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt;Drag selection example&lt;/title&gt;
      &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
          google.load("jquery", "1.3.2");
  
          google.setOnLoadCallback(function ()
          {
              var active = false;
              var lastActionWasError = false;
              $('#tableAppointment tr td:nth-child(2), #tableAppointment tr td:nth-child(3)').mousedown(function (ev)
              {
                  active = true;
                  $(".csstdhighlight").removeClass("csstdhighlight"); // clear previous selection
                  ev.preventDefault(); // this prevents text selection from happening
                  $(".csstdhighlight").removeClass("csstdhighlight");
                  $(".temp_selected").removeClass("temp_selected");
                  $(this).addClass("csstdhighlight");
                  $(this).addClass("temp_selected");
              });
  
              $('#tableAppointment tr td:nth-child(2), #tableAppointment tr td:nth-child(3)').mousemove(function (ev)
              {
                  if (lastActionWasError)
                  {
                      $(".csstdhighlight").removeClass("csstdhighlight");
                      $(".temp_selected").removeClass("temp_selected");
                      lastActionWasError = false;
                  }
                  if (active)
                  {
                      $(this).addClass("csstdhighlight");
                      $(this).addClass("temp_selected");
                  }
                  if ($('.temp_selected').length &gt; 6)
                  {
                      alert("Time slot not more than 45 minutes.");
                      $(this).removeClass("csstdhighlight");
                      $(this).removeClass("temp_selected");
                      lastActionWasError = true;
                      return false;
                  }
              });
          });
      &lt;/script&gt;
      &lt;style type="text/css"&gt;
          .csstdhighlight
          {
              background-color: #ccffcc;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;table id="tableAppointment" cellspacing="1" width="50%" border="1" align="center"&gt;
          &lt;tr&gt;
              &lt;td bgcolor="#ffffff"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  &lt;b&gt;Patient Name&lt;/b&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd" valign="top" width="70px"&gt;
                  8:00AM
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  0
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  15
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  30
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  45
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd" valign="top" width="90px"&gt;
                  9:00AM
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  0
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  15
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  30
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
                  45
              &lt;/td&gt;
              &lt;td class="csstablelisttd"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>