javascript - Change large image when we click on small image - Stack Overflow

There is a link give below open this and then click table styles. It shows all samples of tables when w

There is a link give below open this and then click table styles. It shows all samples of tables when we click these small size table images then its shows in large image area.

/?icid=in00007

I want to create some thing like this or find any similar script.

There is a link give below open this and then click table styles. It shows all samples of tables when we click these small size table images then its shows in large image area.

http://www.pooltables./coventry-pool-table/?icid=in00007

I want to create some thing like this or find any similar script.

Share edited Apr 24, 2020 at 0:37 halfer 20.4k19 gold badges109 silver badges202 bronze badges asked Dec 10, 2010 at 13:00 ChauhanChauhan 2,5919 gold badges37 silver badges46 bronze badges 1
  • The link is broken, so I am voting to put the question on hold. – halfer Commented Apr 24, 2020 at 0:38
Add a ment  | 

3 Answers 3

Reset to default 2

Well, the example you refer to is created in Flash, so to get similar fancy look and feel in javascript is not easy.

But it is quite easy to get similar functionality in javascript, but not with the fancy smooth transitions, and fancy look of the tooltips etc (it is possible, but requires a lot more...). A simple example of displaying image from click on thumbnails could be something like this:

<style>
  table#thumbnails{
    background-color:white;
  }
  table#thumbnails tr td img
  {
    cursor: pointer;
  }
</style>

<script type="text/javascript">
function showImage(image){
  var mainImage = document.getElementById('mainImage');
  mainImage.src = image; 
}
function toggleThumbnails(){
  var thumbnails = document.getElementById('thumbnails');
  if(thumbnails.style.display == 'block'){
    thumbnails.style.display = 'none'; 
  } else {
    thumbnails.style.display = 'block'; 
  }
}
</script>
<input type="button" value="Show/hide thumbnail list" onclick="toggleThumbnails()" />
<table id="thumbnails" style="display:none;">
<tr>
 <td><img src="thumb1.png" title="Item 1" onclick="showImage('img1.png')" /></td>
 <td><img src="thumb2.png" title="Item 2" onclick="showImage('img2.png')" /></td>
 <td><img src="thumb3.png" title="Item 3" onclick="showImage('img3.png')" /></td>
</tr>
<tr>
 <td><img src="thumb4.png" title="Item 4" onclick="showImage('img4.png')" /></td>
 <td><img src="thumb5.png" title="Item 5" onclick="showImage('img5.png')" /></td>
 <td><img src="thumb6.png" title="Item 6" onclick="showImage('img6.png')" /></td>
</tr>
<tr>
 <td><img src="thumb7.png" title="Item 7" onclick="showImage('img7.png')" /></td>
 <td><img src="thumb8.png" title="Item 8" onclick="showImage('img8.png')" /></td>
 <td><img src="thumb9.png" title="Item 9" onclick="showImage('img9.png')" /></td>
</tr>
</table>
<div>
<img id="mainImage" src="img1.png" /> 
</div>

You can try out something on this line .

In above example, I've changed src of img tag on click on image & on mouseleave, original image src is stored.

You'll never find a script that does exactly what you want if what you want is 'something like that'.

You might want to investigate javascript libraries such as jQuery, which make this kind of thing easy by enabling you to bind code to events.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744917182a4600906.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信