添加没有span标签或标题的工具提示/气泡显示 [英] Adding a tool tip / bubble display without span tag or title

查看:141
本文介绍了添加没有span标签或标题的工具提示/气泡显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户将鼠标悬停在某些文字/关键字上时,如何显示工具提示?直接从数据库中检索此文本正文,因此我无法向这些关键字添加任何span或div标记或标题信息。有没有办法自动为页面中包含的某些单词创建工具提示?

How would I go about displaying a tooltip when the user hover overs some text / keywords? This body of text is directly retrieved from the database so I am unable to add any span or div tags or title information to these keywords. Is there a way to automatically create tooltips for certain words that are contained in the page?

如果有任何关于如何解决此问题的好教程,请告诉我。 。

Please let me know if there are any good tutorials available on how to solve this problem.

推荐答案

// Create tooltips dictionary
$tooltips = Array("Word1"=>"This word is word number 1", 
                  "Word2"=>"This word is word number 2");

$content = "Here are Word1 and Word2";
foreach ($tooltips as $word=>$tip){
    $content = preg_replace("/(".$word.")/", "<span title='".$tip."'>$1</span>", $content);
}
echo $content;

这篇关于添加没有span标签或标题的工具提示/气泡显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆