IT技术宅

青春是一个充满活力的季节,即便是我们失去了天使的翅膀,只要我们还有一颗青春的心,那么我们的生活依然能够如阳光般灿烂!......
现在位置:首页 > 代码分享 > js 重写美化title tips提示 更加美观

js 重写美化title tips提示 更加美观

刘振兴     代码分享      2017年05月04日     13250     3条评论  
GIF.gif
//标题提示效果处
var sweetTitles = {
    x: 10,
    y: 20,
    tipElements: "a",
    init: function () {
        $(this.tipElements).unbind("mouseover mouseout mousemove"); //移除之前绑定的时间防止冲突
        $('#tooltip').remove(); //pjax后防止提示未消失
        $(this.tipElements).mouseover(function (e) {
            this.myTitle = this.title;
            this.myHref = this.href;
            this.myHref = (this.myHref.length > 200 ? this.myHref.toString().substring(0, 200) + "..." : this.myHref);
            this.title = "";
            var tooltip = "";
            if (this.myTitle == "") {
                tooltip = "";
            }
            else {
                tooltip = "<div id='tooltip'><p>" + this.myTitle + "</p></div>";
                $('body').append(tooltip);
                $('#tooltip')
                    .css({
                        "opacity": "0.9",
                        "top": (e.pageY + 20) + "px",
                        "left": (e.pageX + 10) + "px"
                    }).show('fast');
            }

        }).mouseout(function () {
            if (this.myTitle != "") {
                this.title = this.myTitle;
                $('#tooltip').remove();
            }
        }).mousemove(function (e) {
            if (this.myTitle != "") {
                $('#tooltip')
                    .css({
                        "top": (e.pageY + 20) + "px",
                        "left": (e.pageX + 10) + "px"
                    });
            }
        });
    }
};
$(function () {
    sweetTitles.init(); //初始化
});
sweetTitles.init(); //pjax回调
评论一下 分享本文 赞助本站 联系站长
IT技术宅
 挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

未显示?请点击刷新

清空信息
关闭评论
吗卡吗卡
吗卡吗卡 2017-11-20 08:35 福建省厦门市海沧区电信 回复
这个是css吧:
/*tips*/
.tooltip{font-size:12px;position:absolute;padding:5px;z-index:100000;opacity:.8;font-family:Microsoft Yahei}.tipsy-arrow{position:absolute;width:0;height:0;line-height:0;border:6px dashed #000;top:0;left:20%;margin-left:-5px;border-bottom-style:solid;border-top:0;border-left-color:transparent;border-right-color:transparent}.tipsy-arrow-n{border-bottom-color:#8aa653}.tipsy-inner{background-color:#8aa653;color:#FFF;max-width:200px;padding:5px 8px 4px 8px;text-align:center;border-radius:3px}
 Windows 7 x64   Google Chrome 61.0.3163.100
风轻云淡
风轻云淡 2017-09-22 20:35 北京市 CZ88.NET 回复
IT技术宅没有css
 Windows 7 x64   Google Chrome 55.0.2883.87
吾爱
吾爱 2017-05-16 20:56 陕西省西安市电信 回复
怎么用呢?能不能详细
 Xiaomi 5   Google Chrome 40.0.2214.89