admin管理员组文章数量:1401171
I am trying to open another image when I press the image button - I am pletely new to html. I heard that you need to use the onclick to get that. Here it is what I am trying:
input type="image" src="img/gallery/5.jpg" onclick="img/floor.jpg"
Where 5.jpg is the thumbnail view and floor.jpg is the target image (present in another directory).
But the above piece of code is not working for me. What is the correct approach?
Why this is failing ?? i used the solution to open a number of images
<a href="img/5.jpg"><img src="img/gallery/5.jpg"/></a>
<a href="img/6.jpg"><img src="img/gallery/6.jpg"/></a>
<a href="img/7.jpg"><img src="img/gallery/7.jpg"/></a>
<a href="img/8.jpg"><img src="img/gallery/8.jpg"/></a>
<a href="img/9.jpg"><img src="img/gallery/9.jpg"/></a>
<a href="img/10.jpg"><img src="img/gallery/10.jpg"/></a>
but every time it opens only the 10.jpg Help thanks
I am trying to open another image when I press the image button - I am pletely new to html. I heard that you need to use the onclick to get that. Here it is what I am trying:
input type="image" src="img/gallery/5.jpg" onclick="img/floor.jpg"
Where 5.jpg is the thumbnail view and floor.jpg is the target image (present in another directory).
But the above piece of code is not working for me. What is the correct approach?
Why this is failing ?? i used the solution to open a number of images
<a href="img/5.jpg"><img src="img/gallery/5.jpg"/></a>
<a href="img/6.jpg"><img src="img/gallery/6.jpg"/></a>
<a href="img/7.jpg"><img src="img/gallery/7.jpg"/></a>
<a href="img/8.jpg"><img src="img/gallery/8.jpg"/></a>
<a href="img/9.jpg"><img src="img/gallery/9.jpg"/></a>
<a href="img/10.jpg"><img src="img/gallery/10.jpg"/></a>
but every time it opens only the 10.jpg Help thanks
Share Improve this question edited Dec 23, 2013 at 21:17 Gabriele Petrioli 196k34 gold badges271 silver badges328 bronze badges asked Dec 17, 2013 at 14:24 NiharNihar 5512 gold badges10 silver badges29 bronze badges 2- 1 How do you want to display the 2nd image? In the same place as the first? Or maybe inside something like a lightbox? – RienNeVaPlu͢s Commented Dec 17, 2013 at 14:27
-
Why not simply
<a href="img/floor.jpg"><img src="img/gallery/5.jpg" /></a>
? – Reeno Commented Dec 17, 2013 at 14:29
2 Answers
Reset to default 5Why use an input and javascript in the first place ?
Just use a link
<a href="img/floor.jpg"><img src="img/gallery/5.jpg"></a>
Just use a an onclick javascript event to toggle the visiblity of the second image.
something like below.
<input type="image" onclick="image.style.display=inline;">
<img src="../5.jpg" id="image" style="display:none;"
本文标签: javascriptHow to open an image by clicking the image buttonStack Overflow
版权声明:本文标题:javascript - How to open an image by clicking the image button - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744249695a2597190.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论