首页 > 解决方案 > jQuery qTip 在键盘点击时显示/隐藏(输入键)

问题描述

我能够在鼠标单击时显示/隐藏 jQuery qTip,但 我想在单击 Enter 键以及单击鼠标时显示/隐藏 qTip。

有人可以帮我解决这个问题。

$('.LoginUserProfile').qtip({
                content: {
                    text: '<span class = "login_jobTitle" title = ' + UserJobTitle + '>' + UserJobTitle + '</span><br/>',
                    title: 'My Profile',
                    //button: 'Close'
                },
                show: {
                    solo: true,
                    click: true,
                },
                show: 'click',
                hide: {
                    event: 'click unfocus'
                },
                position: {
                    my: 'top right',  // Position my top left...
                    at: 'bottom left', // at the bottom right of...
                    viewport: $(window)
                },
                style: {
                    classes: 'qtip-tipsy profile-dropdown',
                    tip: false
                },

标签: javascriptjqueryqtip

解决方案


下面是答案。

var showUserProfile = true;

$('.LoginUserProfile').keyup(function (e) {
    if (e.keyCode === 13) {
        if (showUserProfile) {
            $('.LoginUserProfile').qtip("show");
            showUserProfile = false;
        }
        else {
            $('.LoginUserProfile').qtip("hide");
            showUserProfile = true;
        }
    }
});

推荐阅读