jQuery 图片加载
我需要 jQuery 方面的帮助。我想做的是创建一个小型的、非常非常简单的图片库。
我想在页面左侧放几张小图片。通过单击其中一张小图片,我想将该图片加载到另一个 div 中,并以全尺寸显示。
<a href="image1_big.jpg" class="smallpics" /><img src="image1_small" /></a>
<a href="image2_big.jpg" class="smallpics" /><img src="image2_small" /></a>
<a href="image3_big.jpg" class="smallpics" /><img src="image3_small" /></a>
<div id="bigpic" /><img src="image1_big" /></div>
我所有的 jQuery 尝试都失败了,因为我无法更改这个 bigpic div 中图像的来源。
I need some help in jQuery. What I want to do is to create some kind of a small, very, very easy picture gallery.
I want to have a couple of small pictures on the left-hand-side of my page. By clicking one of these small pictures I'd like to load this picture into another div where it is shown in full size.
<a href="image1_big.jpg" class="smallpics" /><img src="image1_small" /></a>
<a href="image2_big.jpg" class="smallpics" /><img src="image2_small" /></a>
<a href="image3_big.jpg" class="smallpics" /><img src="image3_small" /></a>
<div id="bigpic" /><img src="image1_big" /></div>
All my jQuery attemts failed as I could not change the source of the image within this bigpic div.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该适合你:
我也可以使用这个(而不是前面示例中的类似行):
但第一个选项实际上会执行得更快一点。仅通过一次调用,您将无法分辨出差异,因此如果选项二更易于阅读或编写,您可以使用它。
This should do it for you:
I could have also used this (instead of the similar line in the previous example):
But the first option will actually execute it tiny bit faster. With only one call you won't be able to tell the difference, so if option two is easier to read or write, you can use that.