[英]magnific popup not working
I am using Magnific Popup. 我正在使用Magnific Popup。
$(document).ready(function() {
$('.image-viewer').magnificPopup({
type: 'ajax'
});
});
This is the html: 这是html:
<a href="/site-media/{{ photo.image }}" class="image-viewer"><img class="fest-content-event-content-photo" width = "100%" src="/site-media/{{ photo.thumbnail2 }}" /></a>
But, it isn't working and the console shows error: 但是,它不起作用,控制台显示错误:
Uncaught TypeError: Property '$' of object [object Object] is not a function (index):30
(anonymous function) (index):30
fire jquery.js:3048
self.fireWith jquery.js:3160
jQuery.extend.ready jquery.js:433
completed
What is wrong? 怎么了? I have not loaded tje jquery.js file twice.
我没有加载tje jquery.js文件两次。
First, make sure you've included the jQuery library properly: 首先,确保您已正确包含jQuery库:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Secondly, maybe there is a conflict between jQuery with other libraries, you can try to use: 其次,也许jQuery与其他库之间存在冲突,您可以尝试使用:
jQuery(document).ready(function ($) {
$('.image-viewer').magnificPopup({
type: 'ajax'
});
});
It sounds like you have conflict.. try adding a $
in the document.ready
function 听起来你有冲突..尝试在
document.ready
函数中添加$
$(document).ready(function($) {
$('.image-viewer').magnificPopup({
type: 'ajax'
});
});
Or replace the $
with jQuery
this 或者用
jQuery
替换$
jQuery(document).ready(function(){
jQuery('.image-viewer').magnificPopup({
type: 'ajax'
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.