1

我正在努力弄清楚如何在使用悬停的触发文本链接的焦点上显示jQuery 线索提示。为了可访问性目的,我需要它在浏览内容时(onfocus)工作。

<script>
$(function(){    

  $('a.tip').cluetip({width:200, local:true, cursor:'pointer', sticky: true,closePosition: 'title', arrows: true, titleAttribute:   'title', showTitle:true });
  $(".tip-content").hide();        

  $('a.tip').focus(function() {   
    $(this).click();
  });

});
</script>

HTML:

<a id="load-local" class="tip" href="#cc" rel="#cc" title="Tooltip">Tooltip link</a>
<span class="tip-content" id="cc">Tool tip content</span> 

完全沮丧。看起来这应该是一件简单的事情,但我没有运气。

4

1 回答 1

1

如果您希望它工作,您需要将该activation属性添加到线索提示调用中,如下所示:

$('a.tip').cluetip({activation: 'click', width:200, local:true, cursor: 'pointer', sticky: true, closePosition: 'title', arrows: true, titleAttribute: 'title', showTitle: true });

这样,您的代码应该可以工作,但您的线索提示只会在点击时触发,而不是在悬停时触发。

编辑:为了保持悬停效果,并且由于线索提示没有任何方法来以编程方式显示提示,我认为您将需要两个插件调用,一个有activation: 'click',另一个没有它:

$('a.tip').cluetip({activation: 'click', width:200, local:true, cursor: 'pointer', sticky: true, closePosition: 'title', arrows: true, titleAttribute: 'title', showTitle: true });
$('a.tip').cluetip({width:200, local:true, cursor: 'pointer', sticky: true, closePosition: 'title', arrows: true, titleAttribute: 'title', showTitle: true });

这样,提示将在悬停和单击时弹出,这样,通过链接切换将触发焦点事件,从而触发点击。

于 2011-11-16T12:35:50.067 回答