Jquery 如何旋转多个图像?

Jquery 如何旋转多个图像?,jquery,html,css,Jquery,Html,Css,我有以下代码: $(文档).ready(函数(){ $(“.content image”).each(函数(){ 变量角度=随机角度(); $(“.content image”).css(“变换”、“旋转”(“+角度+”度)”); }); }); 函数randAngle(){ 返回Math.floor(Math.random()*5)+1; } 更改 $(".content-image").css("transform"... 到 因此,它将变换应用于循环中的每个图像,每次变换一个 $("

我有以下代码:

$(文档).ready(函数(){
$(“.content image”).each(函数(){
变量角度=随机角度();
$(“.content image”).css(“变换”、“旋转”(“+角度+”度)”);
});
});
函数randAngle(){
返回Math.floor(Math.random()*5)+1;
}

更改

$(".content-image").css("transform"...

因此,它将变换应用于循环中的每个图像,每次变换一个

$(".content-image").css("transform"...


因此,它将变换应用于循环中的每个图像,一次一个,使用
each()
循环中选择当前元素。为了演示,将随机数更改为0-360

$(文档).ready(函数(){
$(“.content image”).each(函数(){
变量角度=随机角度();
$(this.css(“变换”、“旋转”(+angle+deg)”);
});
});
函数randAngle(){
返回Math.floor(Math.random()*360);
}

each()
循环中使用
这个
,选择当前元素。为了演示,将随机数更改为0-360

$(文档).ready(函数(){
$(“.content image”).each(函数(){
变量角度=随机角度();
$(this.css(“变换”、“旋转”(+angle+deg)”);
});
});
函数randAngle(){
返回Math.floor(Math.random()*360);
}


使用
$(this.css(“变换”、“旋转”(+angle+“deg”))@MarkBaijens它的作品!谢谢。使用
$(this.css(“变换”、“旋转”(+angle+deg)”)@MarkBaijens它的作品!谢谢