I have designed a website navigation as follows:
Home | Login | Help
When t开发者_如何学Pythonhe user's mouse hovers on top of the item (i.e. Home or Login or Help), I would like to show a simple tooltip such as (Go to Homepage, or Please Login in, etc.)
How can I do this in jQuery without any plugin?
Thank you
No need for jQuery - simply edit your HTML:
You can use the title
attribute of the a
element (the link), for example:
<a href="loginPage" title="Please Login">Login</a>
Why would you want to do it without a plugin?
Unless you insist on re-inventing the wheel I'd suggest jQuery Tools Tooltip.
There are also several questions on this topic already.
You can specifity the title='tooltip' in the tag definition in the html
There are many jQuery plugins for tips. I really like QTip and for a simpler version VTip.
There are several jQuery plugins for this, among them QTip, VTip and jQuery Tools Tooltip and I'd really recommend using one of them instead of reinventing something others have already invented.
However, I recommend you use the title
attribute as a fallback option for browsers without javascript. You can easily take the text from the attribute and feed it to the plugin, and then remove the attribute using jQuery.
精彩评论