作者:手机用户2602938185 | 来源:互联网 | 2023-09-18 02:13
Good day guys,
美好的一天,
I've a DOM like this
我有这样的DOM
What I need is, If I click on img1, img2 is replaced with img1, and img3 is replaced with img2 and img1 is replaced with img3 (circular motion 1->2, 2->3, 3->1). and it continuous... and if I click on img3 then it's reverse (1<-2, 2<-3, 3<-1).
我需要的是,如果我点击img1,用img1替换img2,用img2替换img3,用img3替换img1(圆周运动1-> 2,2-> 3,3-> 1)。并且它是连续的...如果我点击img3然后它反向(1 <-2,2 <-3,3 <-1)。
for this I'm using JQuery as follows:
为此,我使用JQuery如下:
$('img#img1').click(function () {
var currentScr = $(this).attr('src');
var secOnd= $('img#img2').attr('src');
var third = $('img#img3').attr('src');
$('img#img3').attr('src', second);
$('img#img2').attr('src', currentScr);
$('img#img1').attr('src', third);
});
$('img#img3').click(function () {
var third = $(this).attr('src');
var first = $('img#img1').attr('src');
var secOnd= $('img#img2').attr('src');
$('img#img2').attr('src', third);
$('img#img3').attr('src', first);
$('img#img1').attr('src', second);
});
It's working fine. now, What I need is, Always the 2nd image should be replace with large image instead of original image... say for example:
它工作正常。现在,我需要的是,总是第二个图像应该替换为大图像而不是原始图像...比如说:
click on img1 (1->2L, 2->3, 3->1). here 2L is large image of img1. and click on img3 (1<-2, 2L<-3, 3<-1). here 2L is large image of img3
点击img1(1-> 2L,2-> 3,3-> 1)。这里2L是img1的大图。然后单击img3(1 <-2,2L <-3,3 <-1)。这里2L是img3的大图
How to do this?, Please help me
怎么做?,请帮帮我
3 个解决方案