I'm trying to build an image upload system like Facebook's where when you mouseover an image, a button (a div, not an actual html button) appears to select an image. So far, I'm using jQuery's hover method. The problem is, when I hover over the image, the button appears, but then when I hover over the button, the function assumes I'm no longer hovering over the image, and the button disappears. Of course then since the button is gone, I'm hovering over the image again and the button reappears. The end result is this sort of flickering effect when I move my mouse on the image.
I can't seem to figure out a way around it. I tried creating a separate hover event for the button itself that removes the hover event for the image and then replaces it on mouseout, but the image mouseout event seems to fire first, and it does nothing.
Only thing I can think is to use a setTimeout, but this seems sloppy. Seeing as Facebook is doing something similar, I'm sure there's a super clean way to handle it.
Any thoughts? Thanks!