Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>With the most basic of changes I believe what you are looking for is what I have done here:</p> <p><a href="http://jsfiddle.net/trakkasure/CtRYd/" rel="nofollow">http://jsfiddle.net/trakkasure/CtRYd/</a></p> <pre><code>// On ready function. $(function(){ var isMouseDown = false; // id for all the cells that were selected at the same time var colorGroupId = Math.floor(Math.random() * 1000); var remove = false; $("#our_table td") .mousedown(function () { var highlight = find_importance_color(); isMouseDown = true; remove = $(this).hasClass(highlight); if (remove) $(this).removeClass(highlight); else $(this).addClass(highlight); $(this).data("highlightedId", colorGroupId); return false; // prevent text selection }) .mouseover(function () { if (isMouseDown) { var highlight = find_importance_color(); if (remove) $(this).removeClass(highlight); else $(this).addClass(highlight); } }); $(document.body) .mouseup(function (event) { isMouseDown = false; // time_importance(event); }); function find_importance_color() { return $('#importance input[name=importance]:checked').val(); } }) </code></pre> <p>I removed the outer function call for select multiple, and adjusted the toggling of colors based on if the selected color is set or not.</p> <p>You only need to create events once, so this should go in a jquery document ready handler.</p> <p>Also, the mouse up event would not have been fired if the mouse was let up outside of the table. SO listening for the event on the document body will solve that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload