Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 不显示更大的图片(上一页()单击()属性())_Jquery_Html - Fatal编程技术网

Jquery 不显示更大的图片(上一页()单击()属性())

Jquery 不显示更大的图片(上一页()单击()属性()),jquery,html,Jquery,Html,我使用下面的代码来显示更大的图片 <body> <div id="Rand"> <a href="#" alt="img/groot/img1.jpg" id="unique name of picture" class="BiggerPic"> <img src="img/thumb/img1.jpg" /> </a> <a href="#" alt="img/groot/img2.jpg" id="unique name of

我使用下面的代码来显示更大的图片

<body>
<div id="Rand">
<a href="#" alt="img/groot/img1.jpg" id="unique name of picture" class="BiggerPic">
<img src="img/thumb/img1.jpg" />
</a>
<a href="#" alt="img/groot/img2.jpg" id="unique name of picture" class="BiggerPic">
<img src="img/thumb/img2.jpg" />
</a>
<a href="#" alt="img/groot/img2.jpg" id="unique name of picture" class="BiggerPic">
<img src="img/thumb/img2.jpg" />
</a>
</div>
<div id="ShowBiggerDivIMG" style="display: none;">
<img id=ShowBiggerIMG src="" />
</div>
</body>

$(document).ready(function(){
var imgScr = $('.BiggerPic').prev('a').attr('alt');
$('.ImageMagnifier').click(function(){
$('#ShowBiggerDivIMG').fadeIn(600);
$('#ShowBiggerIMG').attr('src', imgScr);
})
});

$(文档).ready(函数(){
var imgScr=$('.BiggerPic').prev('a').attr('alt');
$('.image放大镜')。单击(函数(){
$('ShowBiggerDivIMG')。fadeIn(600);
$('ShowBiggerIMG').attr('src',imgScr);
})
});
他唯一返回的是最后一张照片的最后一个链接。
如何获取单击的活动缩略图的alt(链接)以替换为img的src(#ShowBiggerIMG)?

因为您希望获取单击图像的alt

$(document).ready(function(){
       var imgScr;
    $('.BiggerPic').click(function(){
       imgScr =$(this).attr('alt');           
     });

        $('.ImageMagnifier').click(function(){
           $('#ShowBiggerDivIMG').fadeIn(600);
           $('#ShowBiggerIMG').attr('src', imgScr);
        });
    });

这是最有用的一个!首先它重新安装好的,下一次点击返回第一个,然后给右边的一个闪光。所以我只需要从ShowBiggerIMG中清除src,它就被修复了!