我有一个完整的图像和一堆缩略图。我想用单击的任何缩略图的图像链接替换完整图像。这是代码:谢谢
function swapImage() {
var fullCoverImage = document.getElementById("full_cover");
var linkedImage = this.childNodes[0];
var thumbSource = linkedImage.getAttribute("src");
var coverSource = fullCoverImage.getAttribute("src");
var newSource = thumbSource.replace("_thumb","");
fullCoverImage.setAttribute("src", newSource);
}
<a id="slide_thumb" onClick="swapImage();" href="Javascript:void(0);"><img src="images/portfolio/fiction_001_thumb.png" /></a>
<a id="slide_thumb" onClick="swapImage();" href="Javascript:void(0);"><img src="images/portfolio/fiction_002_thumb.png" /></a>
<img id="full_cover" src="images/portfolio/fiction_001.png" />