Jquery 实现缩放悬停插件时出现语法错误
Jquery syntax error while implementing zoom hover plugin
$(document).ready(function(){
$(function(){
$('.my-gallery').imageZoom({
$(this).imageZoom({
zoom: 200
});
});
});
});
HTML:
<link rel="stylesheet"href="{% static 'click-tap-image/dist/css/image-zoom.css' %}" />
<script src="{% static 'click-tap-image/dist/js/image-zoom.min.js' %}"></script>
<div class="slider-for m-2" class="my-gallery">
<img src="{% static 'images/product1.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product2.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product3.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product4.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product5.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product3.png' %}" width="80" class="gallery-image">
</div>
我链接了 jquery click-image-Error in jszoom 插件。这段代码有什么问题。它在 vscode 中显示错误,显示“{”有人可以帮忙吗?
错误是在 $(this).imageZoom
行引起的。但是您不需要此行,因为您已经在调用 $('.my-gallery').imageZoom
。只需传入 Zoom 参数即可
例如:
$(function () {
$('.my-gallery').imageZoom({
zoom: 200
});
});
$(document).ready(function(){
$(function(){
$('.my-gallery').imageZoom({
$(this).imageZoom({
zoom: 200
});
});
});
});
HTML:
<link rel="stylesheet"href="{% static 'click-tap-image/dist/css/image-zoom.css' %}" />
<script src="{% static 'click-tap-image/dist/js/image-zoom.min.js' %}"></script>
<div class="slider-for m-2" class="my-gallery">
<img src="{% static 'images/product1.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product2.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product3.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product4.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product5.png' %}" width="80" class="gallery-image">
<img src="{% static 'images/product3.png' %}" width="80" class="gallery-image">
</div>
我链接了 jquery click-image-Error in jszoom 插件。这段代码有什么问题。它在 vscode 中显示错误,显示“{”有人可以帮忙吗?
错误是在 $(this).imageZoom
行引起的。但是您不需要此行,因为您已经在调用 $('.my-gallery').imageZoom
。只需传入 Zoom 参数即可
例如:
$(function () {
$('.my-gallery').imageZoom({
zoom: 200
});
});