html5tooltipsjs是一款使用纯javacript编写的轻量级tooltips工具提示插件。该tooltips插件不依赖任何框架,内容可带HTML标签,并可以使用预设的CSS3动画来制作tooltips动画效果。
使用方法
基本使用方法
最简单的在某个元素上显示tooltips的方法是在这个元素上添加data-*属性。
<span id="refresh" data-tooltip="Refresh"></span>
高级使用方法
你也可以通过JavaScript来调用该tooltips插件。
html5tooltips({
contentText: "Refresh",
targetSelector: "#refresh"
});
你可以指定tooltips在元素的什么方向上出现。
html5tooltips({
contentText: "Refresh",
stickTo: "right",
targetSelector: "#refresh"
});
你还可以在tooltips中添加额外的说明文本。这些文本会在元素聚焦时显示。这个特性用于在输入框或可编辑字段中使用。你可以使用HTML标签。
html5tooltips({
contentText: "Not less then 8 symbols",
contentMore: "Use lower and UPPER case letters,
num<span style='color:red'>6</span>ers and
spec<span style='color:red'>!</span>al symbols
to make password safe and secure.",
maxWidth: "180px",
targetSelector: "#password"
});
你可以定义多个tooltips,每个tooltips在参数数组中作为一个对象。
html5tooltips([
{
contentText: "Delete",
targetSelector: "#delete"
},
{
contentText: "Refresh",
stickTo: "top",
targetSelector: "#refresh"
},
{
contentText: "Simple to remember",
contentMore: "Check that your login name is not used by anyone else.",
stickTo: "left",
maxWidth: "180px",
targetSelector: "#username"
}
]);
配置参数
-
animateFunction:tooltips可用的CSS3动画类型。可用的动画有:fadein,foldin,foldout,roll,scalein,slidein,spin。 -
color:tooltips可用的预定义颜色。可用值有:daffodil, daisy, mustard, citrus-zest, pumpkin, tangerine, salmon, persimmon, rouge, scarlet, hot-pink, princess, petal, lilac, lavender, violet, cloud, dream, gulf, turquoise, indigo, navy, sea-foam, teal, peacock, ceadon, olive, bamboo, grass, kelly, forrest, chocolate, terra-cotta, camel, linen, stone, smoke, steel, slate, charcoal, black, white, metalic-silver, metalic-gold, metalic-copper,或者任何CSS颜色。 -
contentText:tooltip的内容,可以是HTML标签。 -
contentMore:tooltip中显示的更多内容,会在元素聚焦时显示。 -
disableAnimation:是否禁用动画。 -
stickTo:tooltip显示的位置。可用值有bottom,left,right和top。 -
stickDistance:tooltip和目标元素之间的距离,单位像素。 -
targetSelector:目标元素的CSS选择器。 -
targetXPath:目标元素的xPath值。 -
maxWidth:tooltip的扩展文本的最大宽度。
可用的data-*属性
-
data-tooltip:与contentText参数相同。 -
data-tooltip-animate-function:与animateFunction参数相同。 -
data-tooltip-color:与color参数相同。 -
data-tooltip-more:与contentMore参数相同。 -
data-tooltip-stickto:与stickTo参数相同。 -
data-tooltip-maxwidth:与maxWidth参数相同。






![MBTI 16型人格职业性格测试源码PC+H5自适应完整版基于ThinkPHP框架[亲测可用]](https://www.icbot.net/upload/portal/20250429/32ccad646f32a5f4926b3b7b5ef3232a.png)















