jQuery实例: ToolTip的实现
2008-10-14 12:18
323 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery</title>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
$(function(){
$("[myTip]").hover(function(){
$('<div id="luluTip"><div class="triangle" /></div>')
.insertAfter(this)
.prepend($(this).attr("myTip"));
$(this).mousemove(function(e){
ee=e || window.event;
var x=e.pageX-36;
if(x-2<0)
x=2;
if(x+152>document.body.clientWidth)
x=document.body.clientWidth-152;
$("#luluTip").css({"left":x,"top":e.pageY+18,"display":"block"});
});
},function(){
$("#luluTip").fadeOut('slow',function(){
$(this).remove();
});
})
});
</script>
<style type="text/css">
#luluTip
{
word-wrap:break-word; /**//*自动换行,在FF中对英文和数字无效*/
position:absolute;
width:150px;
color: #a00;
background-color:#FFFFCC;
border:1px solid #a00;
padding:10px;
display:none; /**//*我们先不要让它显示*/
}
#luluTip div.triangle /**//*后代选择器,选择ID为"luluTip"中DIV的类为"triangle"的元素*/
{
background:transparent
url('sj.gif')
no-repeat scroll left top;
position:absolute;
height:17px;
left:20px;
top:-16px;
width:31px;
z-index:999;
}
</style>
</head>
<body>
<input id="btnAjax" name="btnAjax" type="button" value="获取" myTip="sssssss" />
<br/>
<a myTip="这是要显示的内容!" href="#">sssssssssss</a>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jQuery</title>
<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
$(function(){
$("[myTip]").hover(function(){
$('<div id="luluTip"><div class="triangle" /></div>')
.insertAfter(this)
.prepend($(this).attr("myTip"));
$(this).mousemove(function(e){
ee=e || window.event;
var x=e.pageX-36;
if(x-2<0)
x=2;
if(x+152>document.body.clientWidth)
x=document.body.clientWidth-152;
$("#luluTip").css({"left":x,"top":e.pageY+18,"display":"block"});
});
},function(){
$("#luluTip").fadeOut('slow',function(){
$(this).remove();
});
})
});
</script>
<style type="text/css">
#luluTip
{
word-wrap:break-word; /**//*自动换行,在FF中对英文和数字无效*/
position:absolute;
width:150px;
color: #a00;
background-color:#FFFFCC;
border:1px solid #a00;
padding:10px;
display:none; /**//*我们先不要让它显示*/
}
#luluTip div.triangle /**//*后代选择器,选择ID为"luluTip"中DIV的类为"triangle"的元素*/
{
background:transparent
url('sj.gif')
no-repeat scroll left top;
position:absolute;
height:17px;
left:20px;
top:-16px;
width:31px;
z-index:999;
}
</style>
</head>
<body>
<input id="btnAjax" name="btnAjax" type="button" value="获取" myTip="sssssss" />
<br/>
<a myTip="这是要显示的内容!" href="#">sssssssssss</a>
</body>
</html>
相关文章推荐
- jQuery实例: ToolTip的实现
- jQuery实例: ToolTip的实现
- 弹出框(tooltip)模态modal框的实现原理及Jquery的一个实现实例
- jQuery实例: ToolTip的实现
- jQuery实现可用于博客的动态滑动菜单完整实例
- Jquery AjaxUpload实现文件上传功能代码实例教程
- jquery实现带渐变淡入淡出并向右依次展开的多级菜单效果实例
- 基于jQuery实现的Ajax 验证用户名唯一性实例代码
- jQuery实现公告文字左右滚动的实例代码
- jQuery实现的省市县三级联动菜单效果完整实例
- jQuery实例―选项卡的简单实现(js源码和jQuery)
- jquery实现跳到底部,回到顶部效果的简单实例(类似锚)
- Silverlight实用窍门系列:13.基于Popup浮动窗体控件模拟ToolTip的实现【附带实例源码】
- jQuery实现感应鼠标动画效果自动伸长的输入框实例
- jquery实现动态菜单的实例代码
- jQuery实现手机号码输入提示功能实例
- jquery实现回车键触发事件(实例讲解)
- jquery+ajax+C#实现无刷新操作数据库数据的简单实例
- jQuery实现的多屏图像图层切换效果实例
- jquery无刷新验证邮箱地址实现实例