微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

隐藏提示工具提示

如何解决隐藏提示工具提示

我想在用户将鼠标悬停在输入上时显示错误提示。如果用户修复了错误,我不希望在他们悬停时再显示提示我有下面的内容显示它,但是当用户将鼠标悬停在输入框上时,我无法弄清楚如何阻止它显示。有人可以帮忙吗?

$().ready(function () {
    const initialTippy = tippy(document.querySelector('.tippy'));
}

// Simplified validation for this question.
function validate() {
    if (isValid) {
        // Kill the tippy message...which I need help with. 
        // initialTippy.destroy() does not work and I do not get an error.
    }
    else {
        toggleErrorMessage('You have an error');    // Works when I hover over highlighted input Box.
    }
}

// If my input does not validate,this is called. 
function toggleErrorMessage(message) {
    tippy('.tippy',{
        trigger: 'mouseenter',onShow(instance) {
            instance.setProps({ content: message });
        }
    });
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。