本文實例講述了jquery提示效果的用法。分享給大家供大家參考。具體實現方法如下:
			$(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。
希望本文所述對大家的jQuery程序設計有所幫助。
新聞熱點
疑難解答
圖片精選