html - jquery recently added higlighted css can not be remove after alert generate -
http://jsfiddle.net/cyjye/ m new jquery.i have made html table shown in jsfiddle.firstly selection made second row second cell in html table selection made first row second cell.i have allot time patient not more 30 minutes.if user selects more 30 minutes gives alert "time slot not more 30 minutes". alert works correctly added css not removed after alert. , whenever mouse after alert .cell highlighted css. dont want if alert generate added css cell removed , whenever mouseup after alert no cell highlighted css.i tried lot not getting correct way. when highlight 30 minute time , click on select patient button(below html table there select patient(patient getting textbox)button) highlight css removed.
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>drag selection example</title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> 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(); // prevents text selection 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 > 6) { alert("time slot not more 45 minutes."); $(this).removeclass("csstdhighlight"); $(this).removeclass("temp_selected"); lastactionwaserror = true; return false; } }); }); </script> <style type="text/css"> .csstdhighlight { background-color: #ccffcc; } </style> </head> <body> <table id="tableappointment" cellspacing="1" width="50%" border="1" align="center"> <tr> <td bgcolor="#ffffff"> </td> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> <b>patient name</b> </td> </tr> <tr> <td class="csstablelisttd" valign="top" width="70px"> 8:00am </td> <td class="csstablelisttd"> 0 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 15 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 30 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 45 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd" valign="top" width="90px"> 9:00am </td> <td class="csstablelisttd"> 0 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 15 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 30 </td> <td class="csstablelisttd"> </td> </tr> <tr> <td class="csstablelisttd"> </td> <td class="csstablelisttd"> 45 </td> <td class="csstablelisttd"> </td> </tr> </table> </body> </html>
thanks help
to remove highlighed css last selected cell use
$(this).removeclass("csstdhighlight"); $(this).removeclass("temp_selected");
Comments
Post a Comment