Sep
24
2016
jquery模拟title提示效果
作者:
绝缘体.. 发布:
2016-09-24 13:07 分类:
未分类 阅读:
抢沙发
当文字字符长度被限制后,总有些长标题会被截断,用title提示虽简单但会造成页面html代码的冗余,这里用jquery做了一个模拟title的提示效果,具体代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery实现的简单文字提示效果</title>
<script src="http://www.phpernote.com/js/jquery.min.js" type="text/javascript"></script>
<style type="text/css">
#pt_phpernote{
position:absolute;
border:1px solid #333;
background:#f7f5d1;
padding:2px;
color:#333;
display:none;
font-size:12px;
}
</style>
<script type="text/javascript">
$(function(){
var x=10,y=20;
$("a.pt").mouseover(function(e){
$("body").append("<div id='pt_phpernote'>"+ this.text+"<\/div>");
$("#pt_phpernote").css({"top":(e.pageY+y)+"px","left":(e.pageX+x)+"px"}).show("fast");
}).mouseout(function(){
$("#pt_phpernote").remove();
}).mousemove(function(e){
$("#pt_phpernote").css({"top":(e.pageY+y)+"px","left":(e.pageX+x)+"px"});
});
})
</script>
</head>
<body>
<p><a href="#" class="pt">php cli下接受参数的几种方法</a></p>
</body>
</html>
微信扫一扫,打赏作者吧~