jquery实现的提示浮层跟随鼠标移动
作者:bea
jquery实现: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>jquery实现简单文字提示</title> <style type="text/css"> #preview{border:
jquery实现:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery实现简单文字提示</title>
<style type="text/css">
#preview{border:1px solid #cccccc; background:#9900CC;color:#fff; padding:5px; display:none; position:absolute;}
</style>
<script type="text/javascript" src="http://img./jslib/jquery/jquery.js"></script>
</head>
<body>
<a class="preview">把鼠标放到这里1</a>
<br><br><br>
<a class="preview">把鼠标放到这里2</a>
<br><br><br>
<a class="preview">把鼠标放到这里3</a>
<br><br><br>
<a class="preview">把鼠标放到这里4</a>
<br><br><br>
<a class="preview">把鼠标放到这里5</a>
<script type="text/javascript">
this.imagePreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// 可以自己设定偏移值
/* END CONFIG */
$("a.preview").hover(function(e){
$("body").append("<div id='preview'>jquery实现简单文字提示</div>");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("slow");
},
function(){
$("#preview").fadeOut("fast");
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// 页面加载完执行
$(document).ready(function(){
imagePreview();
});
</script>
</body>
</html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery实现简单文字提示</title>
<style type="text/css">
#preview{border:1px solid #cccccc; background:#9900CC;color:#fff; padding:5px; display:none; position:absolute;}
</style>
<script type="text/javascript" src="http://img./jslib/jquery/jquery.js"></script>
</head>
<body>
<a class="preview">把鼠标放到这里1</a>
<br><br><br>
<a class="preview">把鼠标放到这里2</a>
<br><br><br>
<a class="preview">把鼠标放到这里3</a>
<br><br><br>
<a class="preview">把鼠标放到这里4</a>
<br><br><br>
<a class="preview">把鼠标放到这里5</a>
<script type="text/javascript">
this.imagePreview = function(){
/* CONFIG */
xOffset = 10;
yOffset = 30;
// 可以自己设定偏移值
/* END CONFIG */
$("a.preview").hover(function(e){
$("body").append("<div id='preview'>jquery实现简单文字提示</div>");
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("slow");
},
function(){
$("#preview").fadeOut("fast");
});
$("a.preview").mousemove(function(e){
$("#preview")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};
// 页面加载完执行
$(document).ready(function(){
imagePreview();
});
</script>
</body>
</html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- js删除select中重复项的实现代码
- JavaScript 题型问答有答案参考
- JavaScript 学习技巧
- JavaScript Timer实现代码
- 两个比较有用的Javascript工具函数代码
- 类似GMAIL的Ajax信息反馈显示
- JavaScript 10件让人费解的事情
- JQuery 动画卷页 返回顶部 动画特效(兼容Chrome)
- jQuery 处理表单元素的代码
- jQuery 树形结构的选择器
- jQuery 处理网页内容的实现代码
- JS getMonth()日期函数的值域是0-11
- Javascript 浏览器事件小结
- 不同浏览器对回车提交表单的处理办法
- Jquery iframe内部出滚动条
- jquery 问答知识整理
- 改善你的jQuery的25个步骤 千倍级效率提升
- jQuery 改变CSS样式基础代码
- jQuery 添加/移除CSS类实现代码