Hover Text on code surrounded text

隐身守侯 提交于 2019-12-25 08:47:16

问题


Was looking for a way for informational text to show up once the mouse hovers over a few words anywhere within the website. I see that there are some plugins that handle this but they dont seem to do anything witin custom content types created by the site admin. In addition, tey dont sem to work for specific html tags surrounding the text I wish to be a glossary term.

For example, lets say I have the words "Option 1" between two list tags (li) I would want it to read "Here is text" upon someone mousing over "Option 1" which appears in an unordered list.In other words, I specifically want it to work for all instances of "Option 1" that appear enclosed within (li) tags

Is this request too far fetched? Maybe there is a different way to do this entirely. I just want people to be able ot select options from a checkbox, but have a way to see what those options are in detail from that page where they are listed. Tooltips seem to work well for glossary entries so I figured maybe the same could be done.

Seems that most of the tooltip plugins are not setup in lieu of WordPress Custom Content Types.


回答1:


The simplest way is simply to add the title attribute, like to make a list tag that looks like this:

<li title="Here is text">
    Option 1
</li>

Of course, this, you can't style, or modify - it's entirely interpreted by the browser. Alternatively, you could look into creating your own tooltips, using Javascript or CSS3.



来源:https://stackoverflow.com/questions/6686830/hover-text-on-code-surrounded-text

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