Home > Web Front-end > JS Tutorial > body text

Writing a simple jQuery prompt plugin_jquery

WBOY
Release: 2016-05-16 16:25:16
Original
1218 people have browsed it

Very simple code, no more nonsense.

Code:

Copy code The code is as follows:

/**
*November 13, 2014
* Prompt plug-in
*/

(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("

" text "
");

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();
};
})($);

Rendering (move the mouse over the product, a square product details box will be displayed below):

It’s very practical. Friends, feel free to use it and combine it into your own projects

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!