Example analysis of jquery prompt effect

  • 2020-03-30 04:22:24
  • OfStack

This article illustrates the use of jquery prompts. Share with you for your reference. The specific implementation method is as follows:

<p><a href="#" class="tooltip" title=" This is my hyperlink prompt 1."> prompt 1.</a></p>
<p><a href="#" class="tooltip" title=" This is my hyperlink prompt 2."> prompt 2.</a></p>
<p><a href="#" title=" This is a built-in tip 1."> Take prompt 1.</a></p>
<p><a href="#" title=" This is a built-in tip 2."> Take prompt 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();
     });
})

Experience:

Do not append the div element to the p tag, a large deviation value will appear!

The original! The difference between this and $("this") is that if the above this.title is changed to $("this").attr("title"), the mouseout event below will not be able to access the saved title.


Related articles: