【问题标题】:Why javascript won't work in Twitter's Bootstrap even when calling the function and the js file?为什么即使调用函数和 js 文件,javascript 在 Twitter 的 Bootstrap 中也不起作用?
【发布时间】:2012-02-19 22:45:22
【问题描述】:

我无法让 JavaScript 与 Twitter 的 Bootstrap 一起工作。

我有这个

 <p>
     <a href="#" rel="tooltip" title="first tooltip" id="example">
        hover over me
    </a>
</p>

我希望它显示为工具提示。

它不起作用,所以我在 HEAD 中添加了这个:

<script type="text/javascript">
window.onload = function()
{
    if(!window.jQuery)
    {
        alert('jQuery not loaded');
    }
    else
    {
        $(document).ready(function(){
            $('#example').tooltip({'placement':'top', 'trigger' : 'hover'});
        });
    }
}

注意到它仍然无法正常工作,我已经删除了页面内的所有脚本引用,并且只在 HEAD 中添加了这个:

<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js"></script>

我没有调用我下载的任何特定文件,而是热链接原始文件,但工具提示仍然不会出现。

注意:我正在尝试设置一个新的 Drupal 主题,所以我的网站在 Drupal 中(并且页面是一个 tpl.php 文件)。

感谢您的洞察力!!

【问题讨论】:

    标签: javascript twitter-bootstrap


    【解决方案1】:

    如果你想直接使用 github 文件,你需要使用 raw,所以你应该指向 https://raw.github.com/twitter/bootstrap/master/js/bootstrap-tooltip.js 而不是 https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js

    【讨论】:

      猜你喜欢
      • 2013-08-19
      • 2019-04-07
      • 2014-10-25
      • 1970-01-01
      • 2013-08-16
      • 1970-01-01
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多