wilsonpage
wilsonpage

Reputation: 17610

Building a tooltip feature from scratch in jQuery

I want a very dynamic and simple tool-tip feature in my web app (very much like Facebook's). I have looked around at all the jQuery plugins but don't fancy them really, so want to build my own. It needs to be able to display lists as well as single items on hover of certain html elements.

My main question is that is it best to build the html tooltip element in jQuery and then insert into the DOM every time a relevant element is hovered, or have one tool-tip to serve all tool-tip hover activity and just move it around and change the content inside it?

Any tool-tip experience would be of interest!

Upvotes: 0

Views: 412

Answers (3)

wilsonpage
wilsonpage

Reputation: 17610

I ended up constructing and removing a new tooltip instance on each mouseenter/mouseleave. Works really well!

Upvotes: 0

KSDaemon
KSDaemon

Reputation: 366

Well.. You have 2 options:
1) Generate a tooltip every time you need to show it, but don't forget to remove it from DOM, after hide.
2) But IMHO best way is to initialize tooltip only once, and then just position it at right place, modifying its contents.

Upvotes: 2

key2
key2

Reputation: 428

Try tipsy tooltip jquery plugin

http://fishintheriver.com/2009/03/04/a-cool-facebook-style-tooltip-plugin-for-jquery/

But if you wanna do it by yourself then i think 2nd option is good "have one tool-tip to serve all tool-tip hover activity and just move it around and change the content inside it"

Upvotes: 1

Related Questions