Home > Web Front-end > JS Tutorial > body text

基于JQuery的一个简单的鼠标跟随提示效果_jquery

WBOY
Release: 2016-05-16 18:19:20
Original
1404 people have browsed it

1.效果如图

  

2.实现思路

  1 鼠标移入标题(这里是标签)

    创建一个div,div的内容为鼠标位置的文本

    将创建好的div加到文档中

    为提示层设置位置

  2 鼠标移出标题

    移除div

  3 当鼠标在标题内移动时

    同样添加div效果

3.JQuery实现代码

复制代码 代码如下:









";
$("body").append(toolTip);
$("#tooltip").css({
"top" :e.pageY + "px",
"left" :e.pageX + "px"
});
$("#tb a").mouseout(function(){
$("#tooltip").remove();
});
$("#tb a").mousemove(function(e){
$("#tooltip").css({
"top" :(e.pageY+5) + "px",
"left" :(e.pageX+2) + "px"
});
});
//alert("Y:" + e.pageY + "X:" + e.pageX);
});
});






代码很简单主要是用到了JQuery的三个事件mouseover,mouseout,mousemove.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!