开发者

JavaScript onmousemove show div and follow mouse

开发者 https://www.devze.com 2023-01-28 17:42 出处:网络
I have a list of customer records (tr in a table) in my app. When the user hovers their mouse over a record (tr), I want to show a div which hovers over the other records and shows more detailed inf

I have a list of customer records (tr in a table) in my app.

When the user hovers their mouse over a record (tr), I want to show a div which hovers over the other records and shows more detailed information about the record.

I want the div to then move开发者_开发问答 with the mouse- i.e. if they move the mouse 20 pixels to the right so they can see a different field on the record (the tr), the now unhidden div should then move 20 pixels to the right to follow the cursor.

Is this do-able with Javascript/CSS?


Yes. Do the visible/invisible part with the CSS property visiblility:visible/hidden, set position to absolute and then assign values to top (y-coordinate) and left (x-coordinate) on mousemove elements.


Very possible, they're called "Tooltips" which there are probably a vast array of them out there. Looks like there's one here that is lightweight and does what you want.
If you're using a framework (jQuery/prototype/mootools etc), then there will most likely be plugins that will do this too.


For a prepackaged jquery solution: http://jquery.bassistance.de/tooltip/demo/.

Check out the example that has tracking on.

0

精彩评论

暂无评论...
验证码 换一张
取 消