jquery realizes the mouse to move up the pop-up prompt box, moves out disappears the idea and the Code _jquery

Source: Internet
Author: User
train of Thought

1. First of all to locate the elements to achieve this effect, this time through class

2. If the dynamic display of different content, you need to set the title

3. JQ to Elements plus mouseover and mouseout events

4. Again, the popup box follows the mouse and moves on the target element.

5. Then combine mouseover and mouseout into hover
Copy Code code as follows:

Page load Complete
$ (function () {
var x = 10;
var y = 20; Set the Tip box relative to the offset position to prevent occlusion of the mouse
$ (". Prompt"). Hover (function (e) {//mouse over events
This.mytitle = This.title; Assign the title to the custom attribute Mytilte, and shield yourself with hints
This.title = "";
var tooltiphtml = "<div id= ' tooltip ' >" + this.mytitle + "</div>"; Create a hint box
$ ("Body"). Append (tooltiphtml); Add to Page
$ ("#tooltip"). CSS ({
"Top": (E.pagey + y) + "px",
"Left": (E.pagex + x) + "px"
). Show ("Fast"); Sets the coordinates of the prompt box and displays
}, function () {//Mouse out event
This.title = This.mytitle; Reset Title
$ ("#tooltip"). Remove (); Remove Pop-up Box
}). MouseMove (function (e) {//Follow mouse move event
$ ("#toolti"). CSS ({"Top": (E.pagey + y) + "px",
"Left": (E.pagex + x) + "px"
});
});
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.