js点击左右按钮来切换多张图片

var _thtml="";
var imgs=data.img.split(",");
_thtml+="<img id='t1' class='imgs' src='"+imgs[0]+"' style='width: 80%;height: 75%;display: block'>";
	if(imgs.length>1){
	//将图片数组数据存到隐藏input value里
	 $("#tr_img_value").val(data.img)
_thtml+="<img id='tjt1' class='imgs' src='../images/bz_zjt.png' style='width: 8%;height: 						  5%;position: absolute;left: -10%;top: 35%;display: none;z-index:99999;'>";
_thtml+="<img id='tjt2' class='imgs' src='../images/bz_yjt.png' style='width: 8%;height: 5%;position: absolute;left: 82%;top: 35%;z-index:99999;'>";
     }
					$("#tr_img").html(_thtml)
					//获取保存的图片数组数据
                    var imgs3=$("#tr_img_value").val().split(",")
                    var j=0;
                    $("#tjt1").on("click",function () {
                        if(j>0){
                            j--;
                            if(j==0){
                                $("#t1").attr("src",imgs3[j])
                                $("#tjt1").hide();
                                $("#tjt2").show();
                            }else{
                                $("#tjt1").show();
                                $("#tjt2").show();
                                $("#t1").attr("src",imgs3[j])
                            }
                        }
                    })
                    $("#tjt2").on("click",function () {
                        j++;
                        if(j<=imgs3.length-1){
                            if(j==imgs3.length-1){
                                $("#t1").attr("src",imgs3[j])
                                $("#tjt1").show();
                                $("#tjt2").hide();
                            }else{
                                $("#tjt1").show();
                                $("#tjt2").show();
                                $("#t1").attr("src",imgs3[j])
                            }
                        }
                    })
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值