更改多个图像源 Javascript
我正在创建一个简单的图像库,并且我想创建多组图像。单击链接时,链接给定集中的所有图像都会发生变化。
这是我当前的代码:
<ul>
<li><img src="image01.jpg" width="500" height="450"></li>
<li><img src="image02.jpg" width="200" height="450"></li>
<li><img src="image03.jpg" width="530" height="450"></li>
<li><img src="image04.jpg" width="500" height="450"></li>
<li><img src="image05.jpg" width="178" height="340"></li>
<li><img src="image06.jpg" width="400" height="450"></li>
<li><img src="image07.jpg" width="300" height="220"></li>
<li><img src="image08.jpg" width="400" height="450"></li>
<li><img src="image09.jpg" width="500" height="450"></li>
<li><img src="image10.jpg" width="400" height="450"></li>
<li><img src="image11.jpg" width="300" height="450"></li>
<li><img src="image12.jpg" width="300" height="450"></li>
<li><img src="image13.jpg" width="178" height="340"></li>
<li><img src="image14.jpg" width="500" height="450"></li>
<li><img src="image15.jpg" width="200" height="220"></li>
<li><img src="image16.jpg" width="100" height="450"></li>
</ul>
例如,单击 link1 时,源将全部更改为 setA01.jpg、setA02.jpg,单击 link2 时,源将变为 setB01.jpg,依此类推。任何帮助将不胜感激。
I am creating a simple image gallery, and I would like to create multiple sets of images. On the click of a link all of the images in the link's given set will change.
Here is my current code:
<ul>
<li><img src="image01.jpg" width="500" height="450"></li>
<li><img src="image02.jpg" width="200" height="450"></li>
<li><img src="image03.jpg" width="530" height="450"></li>
<li><img src="image04.jpg" width="500" height="450"></li>
<li><img src="image05.jpg" width="178" height="340"></li>
<li><img src="image06.jpg" width="400" height="450"></li>
<li><img src="image07.jpg" width="300" height="220"></li>
<li><img src="image08.jpg" width="400" height="450"></li>
<li><img src="image09.jpg" width="500" height="450"></li>
<li><img src="image10.jpg" width="400" height="450"></li>
<li><img src="image11.jpg" width="300" height="450"></li>
<li><img src="image12.jpg" width="300" height="450"></li>
<li><img src="image13.jpg" width="178" height="340"></li>
<li><img src="image14.jpg" width="500" height="450"></li>
<li><img src="image15.jpg" width="200" height="220"></li>
<li><img src="image16.jpg" width="100" height="450"></li>
</ul>
For example, on the click of link1 the sources would all be changed to setA01.jpg, setA02.jpg, and on the click of link2 the souces would become setB01.jpg, and so on. Any help would be over-gratefully appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您的数字始终是“01、02、03等”,您可以使用如下所示的函数:
针对此列表使用该函数:
将创建以下内容(假设“setA”作为参数传入):
If your numbers will always be "01, 02, 03, etc" you could use a function like the following:
Using that against this list:
Would create the following (assuming 'setA' were passed in as an argument):