jquery: problem with unbinding mousenter() upon mouseup()
<p>I'm building an interface for marking dates on a calendar as being booked. The user 'paints' on the dates they want to mark as booked.</p>

<p>here's how it looks:</p>

<p><img src="http://i39.tinypic.com/4zyu7t.jpg" alt="alt text"></p>

<p>here are the functions:</p>

<pre><code>function load_red_paint(){
    $('td').bind('mousedown', function(){
        $(this).addClass('booked');
        $('td').bind('mouseenter', function(){
            $(this).addClass('booked');
        });
    unbind_brush();
    })  
}

function unbind_brush(){
    $('td').bind('mouseup', function(){
        $('td').unbind('mouseenter');
    });
    $('table').bind('mouseleave', function(){
        $('td').unbind('mouseenter');
    });
}
</code></pre>

<p><strong>the problem:</strong></p>

<p>My unbind_brush() function works great except for if the user mouseup's outside of the calendar, in which case on returning to the calendar the brush is still 'painting'. I tried to fix this my also unbinding on mouseleave of that calendar with this bit:</p>

<pre><code>$('table').bind('mouseleave', function(){
    $('td').unbind('mouseenter');
});
</code></pre>

<p>but with no joy, am i missing something obvious?!!!</p>

<p>edit: added html:</p>

<pre><code>    &lt;div class="table_wrap"&gt;
        &lt;p class="table_title"&gt;Apr&lt;/p&gt;
        &lt;table cellpadding='10'&gt;

            &lt;tr class="col_titles"&gt;
                &lt;td&gt;S&lt;/td&gt;
                &lt;td&gt;S&lt;/td&gt;
                &lt;td&gt;M&lt;/td&gt;
                &lt;td&gt;T&lt;/td&gt;
                &lt;td&gt;W&lt;/td&gt;

                &lt;td&gt;T&lt;/td&gt;
                &lt;td&gt;F&lt;/td&gt;
            &lt;/tr&gt;   

            &lt;tr&gt;
            &lt;td class='indent'&gt; &lt;/td&gt;&lt;td class='indent'&gt; &lt;/td&gt;&lt;td class='indent'&gt; &lt;/td&gt;&lt;td class='indent'&gt; &lt;/td&gt;&lt;td class='indent'&gt; &lt;/td&gt;&lt;td id='1270080000' class='past '&gt; 01 &lt;/td&gt;&lt;td id='1270166400' class='past '&gt; 02 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td id='1270252800' class='past '&gt; 03 &lt;/td&gt;&lt;td id='1270339200' class='past '&gt; 04 &lt;/td&gt;&lt;td id='1270425600' class='past '&gt; 05 &lt;/td&gt;&lt;td id='1270512000' class='past '&gt; 06 &lt;/td&gt;&lt;td id='1270598400' class='past '&gt; 07 &lt;/td&gt;&lt;td id='1270684800' class='past '&gt; 08 &lt;/td&gt;&lt;td id='1270771200' class='past '&gt; 09 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td id='1270857600' class='past '&gt; 10 &lt;/td&gt;&lt;td id='1270944000' class='past '&gt; 11 &lt;/td&gt;&lt;td id='1271030400' class='past '&gt; 12 &lt;/td&gt;&lt;td id='1271116800' class='past '&gt; 13 &lt;/td&gt;&lt;td id='1271203200' class='past '&gt; 14 &lt;/td&gt;&lt;td id='1271289600' class='past '&gt; 15 &lt;/td&gt;&lt;td id='1271376000' class='past '&gt; 16 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td id='1271462400' class='past '&gt; 17 &lt;/td&gt;&lt;td id='1271548800' class='past '&gt; 18 &lt;/td&gt;&lt;td id='1271635200' class='past '&gt; 19 &lt;/td&gt;&lt;td id='1271721600' class='hand today '&gt; 20 &lt;/td&gt;&lt;td id='1271808000' class='hand '&gt; 21 &lt;/td&gt;&lt;td id='1271894400' class='hand '&gt; 22 &lt;/td&gt;&lt;td id='1271980800' class='hand '&gt; 23 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td id='1272067200' class='hand '&gt; 24 &lt;/td&gt;&lt;td id='1272153600' class='hand '&gt; 25 &lt;/td&gt;&lt;td id='1272240000' class='hand '&gt; 26 &lt;/td&gt;&lt;td id='1272326400' class='hand '&gt; 27 &lt;/td&gt;&lt;td id='1272412800' class='hand '&gt; 28 &lt;/td&gt;&lt;td id='1272499200' class='hand '&gt; 29 &lt;/td&gt;&lt;td id='1272585600' class='hand '&gt; 30 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;          &lt;/tr&gt;

        &lt;/table&gt;
</code></pre>
