Write a simple jquery hint plugin _jquery

Source: Internet
Author: User

Very simple code, there is no more nonsense.

Code:

Copy Code code as follows:

/**
* November 13, 2014
* Prompt Plugin
*/

(function ($) {
$.fn.tips = function (text) {
var divtipsstyle = "Position:absolute;" left:0; top:0; Background-color: #dceaf2; padding:3px; Border:solid 1px #6dbde4; Visibility:hidden; line-height:20px; ";
$ ("Body"). Append ("<div class= ' div-tips ' style= '" + Divtipsstyle + "' >" + text + "</div>");

var divtips = $ (". Div-tips");
Divtips.css ("Visibility", "visible");

var top = This.offset (). Top-divtips.height ()-8;
var left = This.offset (). Left;
Divtips.css ("Top", top);
Divtips.css ("left", left);

$ (document). MouseMove (function (e) {
var top = e.clienty + $ (window). scrolltop ()-Divtips.height ()-12;
var left = E.clientx;
Divtips.css ("Top", top);
Divtips.css ("left", left);
});
};

$.fn.removetips = function (text) {
$ (". Div-tips"). Remove ();
};
})($);

The effect chart (the mouse moves above the commodity, will display a square product detail box below):

Very practical, small partners to play under the freedom to integrate into their own projects

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.