Jquery: Unbinding what was bound isn't working like I thought it would, help figuring out why? (JS Fiddle example included)
http://jsfiddle.net/nicktheandroid/GPFxM/28/
I've also explained the situation in the JS Fiddle example.
I binded hover and mousemove, but when unbinding them, i have to ALSO unbind mouseenter and mouseleave to get it to work a little better, but still it doesn't work correctly.
I changed the cursor to Pointer in the hover bind, but when unbinding it I thought the cursor would go back to normal, but it doesn't?
My plugin adds a 'cursor image', which is an image that follows the cursor around when开发者_Python百科 hovering over specific elements. I made a div that has a cursor image when hovering this div, when clicking on the div it unbinds the hover, which should unbind the cursor image, what happens though is that the cursor image sticks to the box, and doesn't fade out like it should.
I just need help getting this straightened out and if you could explain to me what I did wrong, that would be greatly appreciated, thanks so much.
unbind
only takes one event at a time, so your code only ever unbindsmouseover
.- Note that
hover
simply binds bothmouseenter
andmouseleave
. - Why do you think that simply unbinding the events will remove the image also? If you add
$('#tehCursor').fadeOut('fast');
to the click handlers for the disable span and.myBox
, you should see it work like what I think you expect. - You probably should another function to remove the effects of change cursor from the element it was bound to - I'm not sure what the best way to do this might be (keeping in mind jQuery plugin conventions).
Update
My first ever jQuery plugin; I can't claim to understand it all and it probably isn't the most efficient since I basically took the code in this tutorial and adapted it to your needs. This fiddle should be what you're looking for.
精彩评论