如何停止标题属性暂时显示工具提示?

[英]How to stop title attribute from displaying tooltip temporarily?


I've got a popup div showing on rightclick (I know this breaks expected functionality but Google Docs does it so why not?) However the element I'm showing my popup on has a "title" attribute set which appears over the top of my div. I still want the tooltip to work but not when the popup is there.

我有一个弹出的div显示在右击(我知道这打破了预期的功能但是谷歌文档做了它为什么不呢?)但是,我显示弹出窗口的元素有一个“title”属性集,它显示在我的div上方。我仍然希望工具提示可以工作,但在弹出窗口时,我仍然不希望。

What's the best way to stop the tooltip showing while the popup is open/openning?

在弹出窗口打开/打开时停止显示工具提示的最好方法是什么?

Edit: I am using jQuery

编辑:我正在使用jQuery

4 个解决方案

#1


4  

With jquery you could bind the hover function to also set the title attribute to blank onmouseover and then reset it on mouse out.

使用jquery,您可以绑定鼠标悬停函数,将title属性设置为blank onmouseover,然后在鼠标out上重置它。

$("element#id").hover(
 function() {
  $(this).attr("title","");
  $("div#popout").show();
 },
 function() {
  $("div#popout").hide();
  $(this).attr("title",originalTitle);
 }
);

#2


3  

Here is another example of how it can be done by using data for value storage and prop for value assigning

下面是另一个示例,说明如何使用数据进行值存储,使用prop进行值分配

$('[title]').on({
    mouseenter : function()
    {
        $(this).data('title', this.title).prop('title', '');
    },
    mouseleave: function()
    {
        $(this).prop('title', $(this).data('title'));
    }
});

#3


1  

I think setting to blank space and when the popup closes, setting again the proper text. I think this is the easiest way to stop it.

我认为设置为空格,当弹出窗口关闭时,再次设置合适的文本。我认为这是最简单的方法来阻止它。

#4


1  

For me, I didn't care what the content of the title tag was. I just did:

对我来说,我不关心标题标签的内容是什么。我只是做了:

$('a').hover(function() {

    $(this).attr('title', '');

});

Which stopped the title tag from showing.

这阻止了标题标签的显示。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2008/11/13/7de2c6cdcdffc04acd7776595d8bf38f.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com