-1

这是我的 HTML。我已经包含了所有文件,但是......

<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/main.css">
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
<script src="js/bootstrap.js"></script>
</head>

<a href="#" id="tip" data-toggle="popover" data-placement="right" title="first tooltip">hover over me</a>

<script>
$function() {
$('#tip').popover('show');
});
</script>

</body>
</html>

错误在哪里?谢谢你

4

1 回答 1

2

您的脚本缺少左括号:

<script type="text/javascript">
  $(function() {  // missing the opening bracket
    $('#tip').popover('show');
  });
</script>

编辑

html 也不完全正确。下面的代码对我有用。这是jsfiddle也可以证明它确实有效:-)

<html>
<head>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">

    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
</head>
<body>
    <a href="#" id="tip" data-toggle="popover" data-placement="right" title="first tooltip">hover over me</a>

    <script>
        $(function () {
            $('#tip').popover('show');
        });
    </script>

</body>
</html>
于 2013-06-05T12:29:06.040 回答