JQUERY-TIPS Suspension hint plugin sharing _jquery

Source: Internet
Author: User

Because it was written under a Mac, no low-level browser test tools do not have a specific compatibility test, and I am not a front-end and please forgive me, JS Library with the jquery1.11.1, the lower version should also be possible, need to go to the next jquery, just write fun, share, I hope you can improve the

together.

/** * jquery tips hint plugin jquery.tips.js v0.1beta * * * $ (selector). Tips ({//selector for jquery selector * msg: ' Your messages! ',//Your prompt message must be filled with * side:1,///Hint window display position 1,2,3,4 respectively on the upper right Zomer think 1 (upper) optional * color: ' #FFF ',//Hint text color defaults to white optional * bg: ' #F00 ',//Hint window background color default to Red Optional * time:2,//auto turn off time default 2 seconds set 0 do not automatically turn off optional * x:0,//Horizontal offset positive number to right offset negative to left offset default to 0 optional * y:0,//Vertical offset positive number downwards offset negative up default to 0 optional *}) * * *
      /(function ($) {$.fn.tips = function (options) {var defaults = {side:1, msg: ', color: ' #FFF ',
    BG: ' #F00 ', Time:2, x:0, y:0}
    var options = $.extend (defaults, options); if (!options.msg| |
  isNaN (Options.side)) {throw new error (' params error ');
    } if (!$ (' #jquery_tips_style '). Length) {var style= ' <style id= ' jquery_tips_style ' type= ' text/css ' > '; style+= '. Jq_tips_box{padding:10px;position:absolute;overflow:hidden;display:inline;display:none;z-index
    : 10176523;} ';
    style+= '. Jq_tips_arrow{display:block;width:0px;height:0px;position:absolute;} '; Style+ = '. jq_tips_top{border-left:10px solid transparent;left:20px;bottom:0px;} ';
    style+= '. jq_tips_left{border-top:10px solid transparent;right:0px;top:18px;} ';
    style+= '. jq_tips_bottom{border-left:10px solid transparent;left:20px;top:0px;} ';
    style+= '. jq_tips_right{border-top:10px solid transparent;left:0px;top:18px;} '; style+= '. jq_tips_info{word-wrap:break-word;word-break:normal;border-radius:4px;padding:5px 8px;max-width:130px
    ; overflow:hidden;box-shadow:1px 1px 1px #999; font-size:12px;cursor:pointer;} ';
    style+= ' </style> ';
  $ (document.body). append (style);
      } This.each (function () {var element=$ (this); var element_top=element.offset (). Top,element_left=element.offset (). Left,element_height=element.outerheight (),
      Element_width=element.outerwidth ();
      Options.side=options.side<1?1:options.side>4?4:math.round (Options.side); var sidename=options.side==1? ' Top ': options.side==2? ' Right ': options.side==3? ' Bottom ': options.side==4? '
 Left ': ' Top ';     var tips=$ (' <div class= "Jq_tips_box" ><i class= "Jq_tips_arrow jq_tips_ ' +sidename+ '" ></i><div
      class= "Jq_tips_info" > ' +options.msg+ ' </div></div> '). Appendto (Document.body);
      Tips.find ('. Jq_tips_arrow '). CSS (' border-' +sidename, ' 10px solid ' +options.bg);
      Tips.find ('. Jq_tips_info '). css ({color:options.color, backgroundColor:options.bg});
            Switch (options.side) {case 1:tips.css ({top:element_top-tips.outerheight () +options.x,
          LEFT:ELEMENT_LEFT-10+OPTIONS.Y});
        Break Case 2:tips.css ({top:element_top-20+options.x, left:element_left+element_width+options
          . y});
        Break Case 3:tips.css ({top:element_top+element_height+options.x, left:element_left-10+option
          S.Y});
        Break Case 4:tips.css ({top:element_top-20+Options.x, Left:element_left-tips.outerwidth () +options.y});
        Break
      Default:} var Closetime;
        Tips.fadein (' Fast '). Click (function () {cleartimeout (closetime);
        Tips.fadeout (' Fast ', function () {tips.remove ();
        }) if (options.time) {closetime=settimeout (function () {Tips.click ());
        },options.time*1000);
        Tips.hover (function () {cleartimeout (closetime);
          },function () {closetime=settimeout () (function () {Tips.click ();
        },options.time*1000);
    })
      }
    });
  return this;
};

 }) (JQuery);

The above is the entire contents of this article, I hope you can enjoy.

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.