不确定弹出窗口无效的原因。
控制台说:
Uncaught TypeError: Object [object Object] has no method 'magnificPopup' index.html:17
这是我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/magnific-popup.css" />
<script src="js/magnific-popup.js"></script>
<script src="js/jquery.min.js"></script>
</head>
<body>
<a class="demo" href="http://lorempixel.com/50/50">Demo</a>
<script>
$(document).ready(function() {
$('.demo').magnificPopup({
type: "image",
});
});
</script>
</body>
</html>
答案 0 :(得分:2)
以相反的顺序包含您的脚本
<head>
<link rel="stylesheet" type="text/css" href="css/magnific-popup.css" />
<script src="js/jquery.min.js"></script>
<script src="js/magnific-popup.js"></script>
</head>
jQuery应该始终首先包含。
从类型属性
中删除尾随,
$('.demo').magnificPopup({
type: "image" // <== comma shouldn't be here since there is nothing to initialize after this
});