如何使图片库将显示图像更改为缩略图图像?
How can I get the image gallery to change the display image to the thumbnail image?
如何将此图片库中的大图更改为缩略图?我似乎不能使它工作。我需要将缩略图的src属性转换为大src属性的值。
<html>
<head>
<title>title</title>
<link rel="stylesheet" type="text/css" href="CSSChloe.css">
</head>
<body id = "bodyc">
<div id = "space1">
</div>
<div id = "header">
<div class="image">
<img src = "Banner.png" alt= " " width="257" height="43" />
<h4> text</h4>
</div>
</div>
<div id = "space2"> </div>
<div id= "menuBack">
<div id= "menu1"><a href="index.html" style="text-decoration:none;"><p id = "menu2">link</p></a></div>
<div id= "menu1"><a href="about.html" style="text-decoration:none;"><p id = "menu2">link</p></a></div>
<div id= "select"><a href="photo.html" style="text-decoration:none;">
<img src = "back.png" alt = " " width = "257" height = "48" style = "position: absolute; left: -14px; top: -5px;" />
<p id = "menu2" style = "position: absolute; margin-top: 2%;">Photo Gallery</p></a>
</div>
<div id= "menu1"><a href="price.html" style="text-decoration:none;"><p id = "menu2">link</p></a></div>
<div id= "menu1"><a href="testimontials.html" style="text-decoration:none;"><p id = "menu2">link</p></a></div>
<div id= "menu1"><a href="contact.html" style="text-decoration:none;"><p id = "menu2">link</p></a></div>
<div id= "menu3"><img src ="photographylogo.png" width = "150" height = "125" /></div>
</div>
<div id = "space3"> </div>
<div id= "content">
<div style = "width: 60%; height: 100%; float: left;">
<img id = "big" src ="test1.png" width = "400" height = "350" style = "margin-top: 5%; margin-left: 8%;" />
</div>
<div style = "width: 35%; height: 100%; overflow: auto; float:right;">
<img id = "thumb1" onclick = "thumbFunc('test2.png');" src = "test2.png" width = "150" height = "100" />
<img id = "thumb2" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb3" src = " " width = "150" height = "100" />
<img id = "thumb4" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb5" src = " " width = "150" height = "100" />
<img id = "thumb6" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb7" src = " " width = "150" height = "100" />
<img id = "thumb8" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb9" src = " " width = "150" height = "100" />
<img id = "thumb10" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb11" src = " " width = "150" height = "100" />
<img id = "thumb12" src = " " width = "150" height = "100" />
<br/>
<img id = "thumb13" src = " " width = "150" height = "100" />
<img id = "thumb14" src = " " width = "150" height = "100" />
</div>
</div>
<script>
function thumbFunc(a)
{
document.getElementById("big").setAttribute(src, a);
}
</script>
</body>
</html>
首先,改变内联on-click函数的调用方式:
onclick="thumbFunc('test2.png');"
,所以你不需要再输入图像路径:
onclick="thumbFunc(this.src)"
然后,修改你的javascript:
document.getElementById("big").setAttribute(src, a);
到此(如果您喜欢更简单的方式):
document.getElementById("big").src = a;
或者如果您仍然想坚持使用setAttribute
方法,不要忘记将属性(src)与"
符号括起来:
document.getElementById("big").setAttribute("src", a);
演示工作相关文章:
- 当页面包含指向一个图像的多个链接时,fancyBox会复制缩略图辅助图像
- 用较大的图像交换缩略图
- 不应选择缩略图优先图像
- 为缩略图库和较大图像库添加下一个和上一个按钮
- 缩略图图像滑块
- 图像缩略图库中的“下一个”和“上一个”按钮中的“问题”
- 图像库缩略图滑块
- 缩略图库的XML数据图像绑定
- 在缩略图库中显示图像
- 缩略图单击时图像未以模式显示
- JS照片库.使大图像显示和缩略图可单击
- 尝试显示使用 php 和数据库检索的缩略图中的全尺寸图像
- 如何使用jQuery单击其缩略图时显示主图像
- JS-点击缩略图将显示正确的图像
- 动态加载的缩略图显示其他缩略图的全尺寸图像,而不是自己的缩略图(使用javascript悬停效果)
- ExtJS FormPanel,文件上传旁边有图像缩略图
- 显示从文件选择器中选择的图像的图像缩略图
- Jquery缩略图库正在更改所有图像
- 基于缩略图在路径中循环浏览图像
- 如何使用javascript在缩略图中移动多个图像(从phpmyadmin检索)