【JQ学习笔记】提示的效果

<p><a href="#" class="tooltip" title="这是我的超链接提示1.">提示1.</a></p>
<p><a href="#" class="tooltip" title="这是我的超链接提示2.">提示2.</a></p>
<p><a href="#" title="这是自带提示1.">自带提示1.</a></p>
<p><a href="#" title="这是自带提示2.">自带提示2.</a></p>
$(function(){
            $(".tooltip").mouseenter(function(e){
                this.mytitle=this.title
                this.title=""
                var a="<div>"+this.mytitle+"</div>"
                $("body").append(a);
                $("div").css({
                    "top": (e.pageY + y) + "px",
                    "left": (e.pageX  + x) + "px"
                }).show("fast")
            }).mouseout(function(){
                this.title= this.mytitle;
                $("div").remove();
             });
       })

学习心得:

不要在p标签下追加div元素,会出现一个大的偏差值!

原来!this和$("this")是有所不同,如果上文

this.title改写成$("this").attr("title")
会导致下面的mouseout事件无法访问保存下来的title
posted @ 2014-09-24 22:32  Lee_web之路  阅读(289)  评论(0)    收藏  举报