国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jquery插件tooltipv頂部淡入淡出效果使用示例

2024-05-06 15:57:01
字體:
供稿:網(wǎng)友
這是一個加了點淡入淡出效果的頂部tooltip控件,會自動消失,小功能大家參考使用吧

jquery插件tooltipv頂部淡入淡出效果使用示例

 


內(nèi)部使用



復(fù)制代碼 代碼如下:


<head>
    <title></title>
    <link href="base.css" type="text/css" />
    <link href="jquery.tooltip.less" type="text/css">

    <script src="less-1.4.2.min.js" type="text/javascript"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
    <script src="jquery.tooltip.js" type="text/javascript"></script>
</head>
<body>
    <div></div>
    <button>info</button>
    <button>alert</button>
    <button>hide</button>
    <script language="javascript">
        $("#tooltipContainer").tooltip();  //初始化
        function tg1() {
            $("#tooltipContainer").tooltip("info", "據(jù)你的使用和需求的不同...");
        }
        function tg2() {
            $("#tooltipContainer").tooltip("alert", "據(jù)你的使用和需求的不同...");
        }
        function tg3() {
            $("#tooltipContainer").tooltip("hide");
        }
    </script>
</body>

css

復(fù)制代碼 代碼如下:


.tooltip_info
{
    background:green;
    font-size:20px;
    border-radius: 10px;
}
.tooltip_alert
{
    background:yellow;
    font-size:20px;
    border-radius: 10px;
}

jquery.tooltip插件js代碼

復(fù)制代碼 代碼如下:


(function ($) {
    var methods = {
        init: function (options) {
            return this.each(function () {

                var $this = $(this);
                var settings = $this.data('tooltip');
                if (typeof (settings) == 'undefined') {
                    var defaults = {
                        infoCss: 'tooltip_info',
                        alertCss: 'tooltip_alert',
                        disappearTime: 1000
                    }
                    settings = $.extend({}, defaults, options);
                    $this.data('tooltip', settings);
                } else {
                    settings = $.extend({}, settings, options);
                    $this.data('tooltip', settings);
                }
                $tooltip = $("#tooltip");
                $tooltip.hide();
                if ($tooltip.length == 0) {
                    $tooltip = $("<div></div>");
                    $('body').prepend($tooltip);
                    $tooltip.hide();
                }
            })
        },
        info: function (options) {
            return this.each(function () {
                var $this = $(this);
                var setting = $this.data('tooltip');

                clearTimeout($this.data("autoDisappearHandle"));
                $tooltip.html(options);
                $tooltip.removeClass(setting.alertCss).addClass(setting.infoCss);
                $tooltip.fadeIn();
                var hideTooltip = function () {
                    $tooltip.fadeOut();
                }
                $this.data("autoDisappearHandle", setTimeout(hideTooltip, setting.disappearTime));
            })
        },
        alert: function (options) {
            return this.each(function () {
                var $this = $(this);
                var setting = $this.data('tooltip');

                clearTimeout($this.data("autoDisappearHandle"));
                $tooltip.html(options);
                $tooltip.removeClass(setting.infoCss).addClass(setting.alertCss);
                $tooltip.fadeIn();
                var hideTooltip = function () {
                    $tooltip.fadeOut();
                }
                $this.data("autoDisappearHandle", setTimeout(hideTooltip, setting.disappearTime));
            })
        },
        hide: function () {
            return this.each(function () {
                var $this = $(this);
                clearTimeout($this.data("autoDisappearHandle"));
                $tooltip.fadeOut();
            })
        }
    };

    $.fn.tooltip = function () {
        var method = arguments[0];
        if (methods[method]) {
            method = methods[method];
            arguments = Array.prototype.slice.call(arguments, 1);
        } else if (typeof (method) == 'object' || !method) {
            method = methods.init;
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.tooltip');
            return this;
        }

        return method.apply(this, arguments);

    }

})(jQuery);

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 平武县| 乌拉特后旗| 库伦旗| 邛崃市| 德州市| 腾冲县| 正宁县| 遂川县| 阿拉善右旗| 安西县| 乌鲁木齐县| 吉安县| 贵南县| 华池县| 出国| 乐至县| 武川县| 游戏| 蒙阴县| 全州县| 阿坝县| 湘阴县| 陈巴尔虎旗| 永州市| 科技| 嘉义县| 莆田市| 阿克陶县| 洛阳市| 饶阳县| 凤台县| 合川市| 齐齐哈尔市| 铁力市| 苍山县| 定陶县| 庆城县| 常熟市| 会泽县| 大竹县| 曲水县|