Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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
Javascript 保持qTip工具尖端始终可见_Javascript_Jquery_Qtip2 - Fatal编程技术网

Javascript 保持qTip工具尖端始终可见

Javascript 保持qTip工具尖端始终可见,javascript,jquery,qtip2,Javascript,Jquery,Qtip2,我正在使用我的网站上处理一些工具提示。我在模板中为其应用的页面提供了以下代码: HTML <div class="overview"><a href="#"><img class="border-gray" src="src.jpg"></a></div> <div class="estimate"><a href="#"><img class="border-gray" src="src.jpg">

我正在使用我的网站上处理一些工具提示。我在模板中为其应用的页面提供了以下代码:

HTML

<div class="overview"><a href="#"><img class="border-gray" src="src.jpg"></a></div>
<div class="estimate"><a href="#"><img class="border-gray" src="src.jpg"></a></div>
<!-- More HTML similar to above -->
在各个页面上,如果类与页面相关,我希望工具提示可见。IE:
site.com/overview
将始终显示
overview
类的工具提示。正如
site.com/estimate
可以看到工具提示
estimate
一样

我已尝试将此代码添加到页面中,但它不起作用:

$('.overview').qtip({
   hide: false
});
$('.overview').qtip({
    show: { ready: true },
    hide: false

}); 
我所追求的是当页面加载时,工具提示是可见的。不需要鼠标悬停在etc上。可见的工具提示将取决于可见的页面。IE:
/overview
=
.overview
工具提示

我怎样才能做到这一点

更新

以下代码将实现我想要的:

$('.overview').qtip({
   content: 'Overview',
   position: {
     my: 'bottom center', 
     at: 'top center'
},
  show: {
    ready: true
},
  hide: false,
  style: {classes: 'qtip-tipsy'}
});
但是,这部分代码位于模板中,在页面级别不可编辑:

$('.overview').qtip({
  content: 'Overview',
  position: {
    my: 'bottom center', 
    at: 'top center'
  },
   style: {classes: 'qtip-tipsy'}
});
如果我在上面的代码下面尝试此操作,它将不起作用:

$('.overview').qtip({
   hide: false
});
$('.overview').qtip({
    show: { ready: true },
    hide: false

}); 

如果其中一个在页面级别不可编辑,我如何组合这两个?IE:如果我无法在页面级别编辑代码,我将如何将
显示
隐藏
代码添加到上述代码中?

默认显示

$('.overview').qtip({
  content: 'Overview',
  position: {
      my: 'bottom center', 
      at: 'top center'
    },
  style: {classes: 'qtip-tipsy'},
  show: { ready: true }
  });
<script type="text/javascript">
  $(document).ready(function() 
    {
      // Prepare some variables
      var current_url = window.location.host + window.location.pathname;
      var url_array = current_url.split('/');
      // The qtip code
      $('.overview').qtip({
        content: 'Overview',
        position: {
          my: 'bottom center', 
          at: 'top center'
        },
        show: { ready: url_array[1] == overview ? true : false },
        style: {classes: 'qtip-tipsy'}
      });
  });
</script>
这是您需要的线路:

show: { ready: true }
以下是文档:
gTip:
gTip2:

有条件地显示

<?php
  // Get the url
  $current_url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
  // Get the two parts of the url, seperated by: /
  $url_array = explode('/', $current_url);
?>

<script>
  $('.overview').qtip({
    content: 'Overview',
    position: {
      my: 'bottom center', 
      at: 'top center'
    },
    /* Check if the second part of the url is 'overview'
       If it is, add the show ready code */
    <?php if( isset( $url_array[1] ) && $url_array[1] == 'overview' ) : ?>
      show: { ready: true },
    <?php endif; ?>
    style: {classes: 'qtip-tipsy'}
  });
</script>

$('.overview').qtip({
内容:“概述”,
职位:{
我的‘底部中心’,
在:“顶级中锋”
},
/*检查url的第二部分是否为“概述”
如果是,请添加显示就绪代码*/
显示:{ready:true},
样式:{classes:'qtip tipsy'}
});
有条件地仅显示JAVASCRIPT

$('.overview').qtip({
  content: 'Overview',
  position: {
      my: 'bottom center', 
      at: 'top center'
    },
  style: {classes: 'qtip-tipsy'},
  show: { ready: true }
  });
<script type="text/javascript">
  $(document).ready(function() 
    {
      // Prepare some variables
      var current_url = window.location.host + window.location.pathname;
      var url_array = current_url.split('/');
      // The qtip code
      $('.overview').qtip({
        content: 'Overview',
        position: {
          my: 'bottom center', 
          at: 'top center'
        },
        show: { ready: url_array[1] == overview ? true : false },
        style: {classes: 'qtip-tipsy'}
      });
  });
</script>

$(文档).ready(函数()
{
//准备一些变量
var current_url=window.location.host+window.location.pathname;
var url_array=当前_url.split('/');
//qtip代码
$('.overview').qtip({
内容:“概述”,
职位:{
我的‘底部中心’,
在:“顶级中锋”
},
show:{ready:url_array[1]==概览?true:false},
样式:{classes:'qtip tipsy'}
});
});

Uhmm。不使用工具提示,而只是显示一个
div
?@JustinSatyr如何?为了保持一致性,我更喜欢这种方法。感谢您的帮助,这确实是我需要的正确代码,但是,我无法编辑部分代码,因为我在多个页面的模板中有它。请参阅我的问题更新。因此,您是否可以编辑模板以添加show:{ready:true},有条件地与我更新的答案相同?是的,但是,我不能使用php(我使用的是托管CMS)。如果没有其他方法,我将删除模板。额外的工作要做,但不是不可能。不。。。那么让我们试试javascript。请稍等片刻,更新原始帖子。问题:没有获取概览名称的命令吗?您使用的是什么CMS?Business Catalyst是我的CMS。我将尝试一下JS。ThanksIt看起来像是原始海报(OP)已经声明,如果他们把它放在代码后面,这对他们不起作用。至少,这需要某种解释。