How to add tooltip to a non hyperlink HTML tag

回眸只為那壹抹淺笑 提交于 2019-12-24 01:02:07

问题


Is there anyways to add tooltips to a non hyper link?

ie . I want to have a mouse over tooltip when it goes over a text I would appreciate a working example of tooltip that is not based on a hyperlink

Thanks


回答1:


If by tooltip you mean the title attribute, you can apply that to a lot of different HTML elements. For example span:

<span title="This is my tooltip">roll over me!</span>​

http://jsfiddle.net/Curt/cBHf7/


However if you're referring to javascript tooltips, then these can also be applied to elements other than the anchor:

http://www.1stwebdesigner.com/css/stylish-jquery-tooltip-plugins-webdesign/




回答2:


There are many jQuery plugins that will accommodate this behavior. You can tooltip on jQuery selectors. Or just use the "title" attribute.

http://www.1stwebdesigner.com/css/stylish-jquery-tooltip-plugins-webdesign/




回答3:


<span title="this is the tooltip">Text user will see on page goes here</span>

You can add a title attribute to almost all HTML tags like this, apart from <base>, <head>, <html>, <meta>, <param>, <script>, <style>, and <title>. More info from W3Schools here.

There are various JavaScript options available, the advantage of which is that you can alter the syling e.g. make the tooltip bigger, or add line breaks in the text. The downside is that it's more complex to implement and might impact on page responsiveness if you have lots. Your call :)



来源:https://stackoverflow.com/questions/9995542/how-to-add-tooltip-to-a-non-hyperlink-html-tag

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!