zoukankan      html  css  js  c++  java
  • js的title提示

    $(function() {
        //先在页面创建一个层
        var jqtip = $("<div id='jqtip20130719'" +
            "style='padding: 10px; " +
            "border: 1px solid red;" +
            "background-color: white; " +
            "position: absolute; " +
            "z-index:10001;" +
            "display: none; " +
            "font-family: 宋体; " +
            "font-size: 12px'>fafsdfsa" +
            "</div>");
        $(document.body).append(jqtip);
    });
    (function (window, undefined) {
        var tips = {
            init:function(callback){
                $("[title]").css({
                    'cursor': 'help'
                }).bind("focus", function () {
                    var tit = this.getAttribute('title');
                    this.setAttribute('msg', tit);
                    this.setAttribute('title', '');
                    $("#jqtip20130719").html(tit.replace(/(\n)/g, '<br/>')).css({
                        'left': $(this).position().left,
                        'top': $(this).position().top + 20
                    }).show();
                });
                $("[title]").bind("blur", function () {
                    this.setAttribute('title', this.getAttribute('msg'));
                    $("#jqtip20130719").hide();
                    if (callback)
                        callback();
                });
            }
        };
        window.tip = tips;
    })(window);

    页面调用:

    tip.init(回调函数);

  • 相关阅读:
    HDU 1573: X问题
    HDU 1370: Biorhythms
    Break Number --AtCoder
    Cat Snuke and a Voyage --AtCoder
    Fennec VS. Snuke --AtCoder
    Splitting Pile --AtCoder
    Sharing Cookies --AtCoder
    GLB串
    派(Dispatch)
    你知道那棵杨树底下有什么吗
  • 原文地址:https://www.cnblogs.com/contraII/p/3201018.html
Copyright © 2011-2022 走看看