Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用qtip jquery工具提示插件时,屏幕上只有一个工具提示处于活动状态_Jquery_Qtip - Fatal编程技术网

使用qtip jquery工具提示插件时,屏幕上只有一个工具提示处于活动状态

使用qtip jquery工具提示插件时,屏幕上只有一个工具提示处于活动状态,jquery,qtip,Jquery,Qtip,我在一个页面上的多个元素(图像)上使用jquery qtip工具提示。我试图在特定的时间只在页面上显示一个工具提示。如果显示一个工具提示并触发另一个工具提示以打开,则当前打开的实例应关闭。但是,工具提示的多个实例仍显示在页面上。以下是我的jquery: <script type="text/javascript"> $(document).ready(function () { //****** tooltips **********

我在一个页面上的多个元素(图像)上使用jquery qtip工具提示。我试图在特定的时间只在页面上显示一个工具提示。如果显示一个工具提示并触发另一个工具提示以打开,则当前打开的实例应关闭。但是,工具提示的多个实例仍显示在页面上。以下是我的jquery:

<script type="text/javascript">
        $(document).ready(function () {

            //****** tooltips **********
            $('img.help').hover(function () {

          // Destroy currrent tooltip if present
          //if ($(this).data("qtip")) $(this).qtip("destroy");

          $(this) // Set the links HTML to the current opposite corner
            .qtip({
                content: 
                {
                    text: 'this is the tooltip, better to use the alt attribute of the image or use html div content somewhere on the page', 
                        title: {
                        text: 'This toolip title',
                        button: 'Close'
                        }
                },
                position: {
                    corner: {
                        tooltip: 'bottomLeft', // Use the corner...
                        target: 'topRight' // ...and opposite corner
                    }
                },
                show: {
                    solo: true,
                    when: false, // Don't specify a show event
                    ready: true // Show the tooltip when ready
                },
                hide: false, // Don't specify a hide event
                style: {
                    border: {
                        width: 5,
                        radius: 10
                    },
                    padding: 10,
                    textAlign: 'left',
                    tip: true, // Give it a speech bubble tip with automatic corner detection
                    name: 'blue' // Style it according to the preset 'cream' style
                    // name: 'light' // Style it according to the preset 'cream' style
                }
            });


      });

});

$(文档).ready(函数(){
//******工具提示**********
$('img.help')。悬停(函数(){
//销毁当前工具提示(如果存在)
//if($(this.data(“qtip”))$(this.qtip(“destroy”);
$(this)//将链接HTML设置为当前的对角点
.qtip({
内容:
{
text:'这是工具提示,最好使用图像的alt属性或页面上的某个位置使用html div内容',
标题:{
文本:“此工具IP标题”,
按钮:“关闭”
}
},
职位:{
角落:{
工具提示:'左下',//使用角点。。。
目标:“右上角”/…和对面角
}
},
展示:{
索洛:没错,
当:false时,//不指定显示事件
就绪:true//就绪时显示工具提示
},
hide:false,//不指定隐藏事件
风格:{
边界:{
宽度:5,
半径:10
},
填充:10,
textAlign:'左',
提示:正确,//给它一个带有自动角点检测的语音气泡提示
名称:“蓝色”//根据预设的“奶油”样式设置样式
//名称:'light'//根据预设的'cream'样式设置样式
}
});
});
});
html:


护理人员
视野

我猜测,即使将solo设置为true,它们仍然显示的原因是,qtip的所有实例都具有相同的类。在同一页面上处理多个工具提示时,我的qtips实例上总是有不同的类名,这种方式对我很有效

如果由于某种原因,这不起作用,您可以尝试在
beforeShow
api方法中隐藏所有工具提示

$('#tooltip').qtip({
   ...
   api: {
      beforeShow: function() {
         $('img.help').qtip("hide");
      }
   }
});

这是班级问题。我重新命名了这些类,以“help_”+一个唯一的名称开头,所有这些类都按预期工作。谢谢你的小费。
$('#tooltip').qtip({
   ...
   api: {
      beforeShow: function() {
         $('img.help').qtip("hide");
      }
   }
});