嗨,我想知道如何在JavaScript函数中为我的照片添加href。 我想将每张照片连接到某个网站,但我不知道该怎么办
<body onload="showRandomImage()">
<img id="myimage" />
<script type="text/javascript">
function showRandomImage() {
var theImage = document.getElementById('myimage');
var thePath = 'images/';
var thePictures = new Array();
thePictures[0] = 'photo1.jpg';
thePictures[1] = 'photo2.jpg';
thePictures[2] = 'photo3.jpg';
thePictures[3] = 'photo4.jpg';
thePictures[4] = 'photo5.jpg';
thePictures[5] = 'photo6.jpg';
thePictures[6] = 'photo7.jpg';
var theTime = new Date();
var theWeekday = theTime.getDay();
var imagePath = thePath + thePictures[theWeekday];
theImage.src = imagePath;
theImage.alt = thePictures[theWeekday];
theImage.title = thePictures[theWeekday];
}
</script>