如何在事件就绪或加载时激活线索提示?
当用户的鼠标悬停在(或,可选地,单击)您在脚本中指定的任何元素上时,线索提示插件允许您轻松显示精美的工具提示。如果元素包含标题属性,则其文本将成为线索提示的标题。
默认情况下,工具提示会在悬停您应用它的元素时显示(请参阅默认选项)
这可以更改为click
事件,我将同时演示。
这个想法是以编程方式触发事件mouseenter
(没有真正的悬停事件,而是mouseenter和mouseleave的组合)。
您可以通过使用.trigger('mouseenter')
或.mouseenter()
假设您要打开链接上的工具提示:
<a href="#" id="mylink" title="This is the title|The first the content.|In this case, the delimiter is a pipe">My link</a>
您将拥有以下 javascript:
$(document).ready(function() {
var $link = $('#mylink');
// first initialize the plugin
$link.cluetip({
splitTitle: '|'
});
// trigger the event
$link.mouseenter(); // or $link.click();
});
这是一个jsfiddle供您使用。
hover、.mouseenter()、 .click( )和.trigger()的文档