编写自己的jQuery提示框(Tip)插件

2020-05-23 06:00:53易采站长站整理

            html : false,//是否允许内容为html元素
            template : ‘<div class=”tip”><div class=”tip-inner”><h3></h3><div class=”tip-container”></div></div></div>’//弹出框模版
        }

最后上高清无码源码有兴趣的看看,没兴趣的ctrl+c,ctrl+v吧


!function($){
    var Tip = function(element, options){
        this.init(element, options);
    }
    Tip.prototype = {
        constructor : Tip,
        init : function(element, options){
            this.element = $(element);
            this.options = $.extend({},this.defaultOptions,options);
        },
        show : function() {
            if (!this.tip) {
                this.tip = this.getTip();
                var title = this.tip.find(“h3”),
                    container = this.tip.find(“.tip-container”);
                //设置标题
                title.text(this.options.title);
                //设置内容
                if (this.options.html) {
                    container.html(this.options.content);
                } else {
                    container.text(this.options.content);
                }
                //添加tip到body
                $(“body”).append(this.tip);
                //计算tip的位置