简体   繁体   English

jQuery cluetip激活

[英]jQuery cluetip activation

How make activate cluetip on event ready or onload? 如何使事件准备就绪或加载时激活提示

The clueTip plugin allows you to easily show a fancy tooltip when the user's mouse hovers over (or, optionally, clicks on) any element you designate in your script. 当用户的鼠标悬停在脚本中指定的任何元素上(或选择单击)时,使用clueTip插件可以轻松显示精美的工具提示。 If the element includes a title attribute, its text becomes the heading of the clueTip. 如果元素包含title属性,则其文本成为clueTip的标题。

By default the tooltip is shown while hovering the element you applied it on (see the default options ) 默认情况下,将鼠标悬停在您应用了元素的元素上时会显示工具提示(请参阅默认选项
This can be changed to the click event, I'll demonstrate both. 可以将其更改为click事件,我将对此进行演示。

The idea is to programmatically trigger the event mouseenter (there no real hover event but a combination of mouseenter and mouseleave ). 这个想法是通过编程触发事件mouseenter (没有真正的悬停事件,而是mouseentermouseleave的组合)。

You can do this by using .trigger('mouseenter') or .mouseenter() 您可以使用.trigger('mouseenter').mouseenter()

Let's say you want to open the tooltip on a link: 假设您要在链接上打开工具提示:

<a href="#" id="mylink" title="This is the title|The first the content.|In this case, the delimiter is a pipe">My link</a>

You'll have the following javascript: 您将使用以下javascript:

$(document).ready(function() {

    var $link = $('#mylink');

    // first initialize the plugin
    $link.cluetip({
        splitTitle: '|'
    });

    // trigger the event
    $link.mouseenter(); // or $link.click(); 

});

Here is a jsfiddle for you to play with. 这是一个供您使用的jsfiddle

Documentation of hover , .mouseenter() , .click() and .trigger() 悬停.mouseenter(),.click ().trigger()的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM