这是我的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>
错误在哪里? 谢谢
答案 0 :(得分: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>