我有代码来显示带有描述的图像,该图像在每次重新加载页面时都会随机生成。
是否可以使用户在再次访问该页面时看到带有说明的相同图像?
<img id='image'>
<p id='textimage'></p>
var quotes = [{
img: "01.png",
quote: "text1"
},
{
img: "02.png",
quote: "text2"
},
{
img: "03.png",
quote: "text3"
}
];
function showquote() {
var q = quotes.length;
var whichquote = quotes[Math.round(Math.random() * (q - 1))];
document.getElementById('textimage').innerHTML = whichquote.quote;
document.getElementById('image').src = whichquote.img;
};
showquote();