javascript获胜的原因'我不在Twitter上工作;s Bootstrap,即使在调用函数和js文件时也

Why javascript won't work in Twitter's Bootstrap even when calling the function and the js file?

本文关键字:调用 Bootstrap 函数 文件 js 获胜 javascript Twitter 工作      更新时间:2023-09-26

我无法让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文件)。

感谢您的真知灼见!!

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