Is there a way to change an image randomly when hovering over it? The hover effect is working fine, but the image does not revert back when the mouse moves out. Any suggestions on how to fix this?
var arr = ["020", "053", "306", "035", "930"];
function getRandomImage() {
var index = Math.floor(Math.random() * arr.length);
return arr[index];
}
$(function(){
$(".size-woocommerce_thumbnail").hover(function(){
var image = getRandomImage();
$(this).attr("srcset", function(index, attr){
return attr.replace("070", image);
});
$(this).attr("src", function(index, attr){
return attr.replace("070", image);
});
}, function(){
$(this).attr("srcset", function(index, attr){
return attr.replace(image, "070");
});
$(this).attr("src", function(index, attr){
return attr.replace(image, "070");
});
});
});