js代码(function ($) {    function dialogue(content, title, width, height, call) {
        $("<div/>").qtip({
            content: {
                text: content,
                title: title
            },
            position: {
                my: 'center',
                at: 'center',
                target: $(window)
            },
            show: {
                ready: true,
                modal: {
                    on: true,
                    blur: false
                }
            },
            hide: false,
            style: {
                classes: 'qtip-blue',
                width: width,
                height: height
            },
            events: {
            render: function (event, api) {
                $('button', api.elements.content).click(function (e) {
                        api.hide(e);
                    });
                },
                hide: function () { (call && call()); }
            }
        });
    }
    $.alert = function (title, content, width, height, call) {
        var message = $('<p />', { text: content }),
            ok = $('<button />', { text: '确定', 'class': 'full' });        dialogue(message.add(ok), title, width, height,call);
    };})(jQuery);
html调用
 $.alert("提示", "用户名不能为空!", 120, 80, function () { $("#xqname").focus(); });

解决方案 »

  1.   


    render: function (event, api) {
                    $('button', api.elements.content).click(function (e) {
                            api.hide(e);
                        }).focus();
                    },如果是弹出框里的按钮聚焦的话应该是这样。
      

  2.   

    什么版本的qtip,最新版本的qtip事件配置是api节点,不是events,也没有render事件                api: {
                        onShow: function (event) {
                            $('button', this.elements.content).click(function (e) {
                                api.hide(e);
                            }).focus();
                        },
                        onHide: function () { return; (call && call()); }
                    }