2012-01-31 70 views
2

我的代码用于工作,直到我不知道我改变了什么,我从头开始一切,但它仍然不显示工具提示,有人可以告诉我什么是错的代码? 甚至更​​好,有没有其他(更简单)的方式来实现工具提示?qTip2不工作

<html> 
<head> 

<link type="text/css" rel="stylesheet" href="css/jquery.qtip.css" />  
<title>My site</title> 
</head> 
<body> 
<a href="#">ZA</a> 
    <div id="jj" style="display: none;">HHHHHHH</div> 
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script> 
    <script type="text/javascript" src="js/jquery.qtip.js"></script> 
    <script type="text/javascript"> 

     $('a').qtip({ 
     content: { 
     text: $('#jj') // Add .clone() if you don't want the matched elements to be removed, but simply copied 
    } 
    }) 

</script> 
</body> 
</html> 
+0

为什么不在头部添加脚本,你有没有试过寻找一个错误的调试工具,就像firefox中的firebug – Rafay 2012-01-31 20:26:36

回答

1

是不是你错过了onload?

<script type="text/javascript"> 
$(function() { 
    $('a').qtip({ 
     content: { 
      text: $('#jj') 
     } 
    }); 
}); 
</script> 

编辑:上面的代码中最肯定的作品,看到jsfiddle

确保您qtip.js和qtip.css加载和最近

1

试试这个:

$('a').qtip({ 
    content: $('#jj').text() 
}); 

还是做评论说什么,而克隆的元素 - 你可能不得不明确地表现出来:

$('a').qtip({ 
    content: { 
     text: $('#jj').clone().show() 
    } 
}); 
+1

它也行不通!即使当我使用“文本”bla bla bla“”它也行不通(没有引用c) – 2012-01-31 20:18:38

1

你需要把你的JavaScript qtip一个文档中准备。

$(function() { 
    $('a').qtip({ 
     content: { 
      text: $('#jj').clone() 
     } 
    }); 
}); 
0

两件事情,你可以尝试

  1. 移动脚本到你的头节

  2. 包裹ready处理

    $(document).ready(function(){ 
    
        $('a').qtip({ 
         content: { 
         text: $('#jj') // Add .clone() if you don't want the matched elements to be removed, but simply copied 
        } 
        }); 
    }); 
    
内的JavaScript/jQuery代码
+0

你检查了萤火虫可能的错误 – Rafay 2012-01-31 20:33:55

+0

以及如何做到这一点? – 2012-01-31 20:36:37

+0

转到http://getfirebug.com/在安装完成后安装这个插件重新启动FireFox并加载你遇到问题的页面,点击'f12'它会调出控制台,其余的你可以探索... – Rafay 2012-01-31 20:41:10

0
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 

<link type="text/css" rel="stylesheet" href="Scripts/qTip/jquery.qtip.css" />  
<title>My site</title> 
</head> 
<body> 
<a href="#">ZA</a> 
    <div id="jj" style="display: none;">HHHHHHH</div> 
    <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-2.1.1.min.js"></script> 
    <script type="text/javascript" src="Scripts/qTip/jquery.qtip.js"></script> 
    <script type="text/javascript"> 
     $(function() { 
      $('a').qtip({ 
       content: { 
        text: $('#jj') 
       } 
      }); 
     }); 
</script> 
</body> 
</html> 
+0

欢迎来到StackOverflow。原始海报问他/她的代码出了什么问题。你能否更新你的答案并解释什么是错的请。 – kkuilla 2014-10-03 13:28:44