600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > html 提示框 js JavaScript实现短暂提示框功能

html 提示框 js JavaScript实现短暂提示框功能

时间:2023-01-07 10:20:15

相关推荐

html 提示框 js JavaScript实现短暂提示框功能

业务场景:当鼠标移入某元素时,显示提示框进行介绍。当鼠标移除时,会自动消失。引入ToolTip.js和ToolTip.css

主方法:ToolTip.show(需要提示的元素id,随意不重复即可,要提示的html文本,宽(可不指定),高(可不指定));

ToolTip.show(obj,id,html,width,height);

效果如下:

1.显示文本:

3:显示网站

js代码:F:\Html5\Plugins\ToolTip\js\ToolTip.js

document.body.clientWidth) {

left = document.body.clientWidth / 2;

}

toolTip.style.left = left + "px";

toolTip.style.top = top + 20 + "px";

parent.onmouseleave = function (ev) {

setTimeout(function () { //延迟:

document.getElementById(childId).style.display = "none";//隐藏

},300);

}

} else {

//显示

document.getElementById(childId).style.display = "block";

}

},/**

* 调用入口

*/

ToolTip.show = function (parentId,height) {

var parent = document.getElementById(obj)

parent.onmouseenter = function (ev) {

ToolTip._showTip(parentId,height)

}

}

window.ToolTip = ToolTip;

})();//为防止污染,将方法写在匿名函数中

HTML代码:F:\Html5\Plugins\ToolTip\ToolTip.html

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。