jquery - 如何使用在运行时分配给页面元素的 qTip2 创建工具提示

标签 jquery jquery-plugins qtip2

我试图创建一个 qTip2 气泡,但在加载时不显示。然后将其显示在单击的任何图像下方。

请告知执行此操作的最佳方法是什么。 (使用qTip解决气泡走出屏幕的问题)。

谢谢

编辑:

查看 http://jsfiddle.net/jnbPP/5/ 的问题(寻找正确的方法来做到这一点)

最佳答案

那么你需要在点击时加载它,例如:

$('img[title]').live('click', function(event) {
        $(this).qtip({
              overwrite: false,
              content: {           
                 text: $(this).attr('title') ,
              },
              position: {
                  my: 'top center', 
                  at: 'bottom center', 
                  adjust : {
                    screen : true
                  }
              },  
              show: {
                 event: event.type,
                 ready: true,
                 solo: true
              },
              hide: 'unfocus',
                style: {
                    classes: 'ui-tooltip-light'
              }
           });
    });

看看我的 fiddle :EXAMPLE

使用

adjust : {
     screen : true
}

将工具提示保留在屏幕上。

给你CLICK

$('img[title]').live('click', function(event) {
    var content = $('#settings').clone();
    $('input', content).val( $(this).width() );

    $(this).qtip({
      overwrite: false,
      content: {           
            text: content,
            title: {
                text: ' ',
               button: true
            }
         },
         position: {
             my: 'top center',  // Position my top left...
             at: 'bottom center', // at the bottom right of...
             viewport: $(window)
          },

      show: {
         event: event.type,
         ready: true,
         solo: true
      },
      hide: 'unfocus',
         style: {
               classes: 'ui-tooltip-ajax ui-tooltip-light'
         }
   });
});

关于jquery - 如何使用在运行时分配给页面元素的 qTip2 创建工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4800572/

相关文章:

javascript - 单击复选框时检测工具提示事件

AngularJS 绑定(bind) jQuery qTip2 插件

javascript - 如何将 jQuery/Javascript 函数转换为方法

javascript - 没有 Node.js 的 Typed.js 安装

Java json对象通过名称调用函数

asp.net-mvc - 将 qTip 与 ASP.NET MVC 非侵入式 javascript 验证结合使用

php - jquery 使搜索自动建议列表从下到上打开(相反方向)

javascript - Fancybox 递归导致堆栈溢出

jquery - 如何为 DotNetNuke 使用 Aquantum 多文件 uploader (Jquery 插件)?

jquery - masonry 元素相互坍塌