duankang5882 2014-10-17 16:25
浏览 64

jquery将图像加载到div奇怪的行为中

I've made slideshow with thumbnails at it's side.

Here, basically a div which displays the image and after clickimg on a particular thumbnail, it's related picture will be dynamically displayed in the main div (#display #slideshowpic). Here is the code example,

<div id="container">
    <div id="display">
      <img id="slideshowpic" src="initial.jpg">
    </div>

    <div id="thumbs">
      <img class="thumb" id="image1">
      <img class="thumb" id="image2">
      <img class="thumb" id="image3">
      <img class="thumb" id="image4">
      <img class="thumb" id="image5">
   </div>
</div>

And here is the javascript,

$('.thumb').click( function() {
        $('#slideshowpic').attr('src',"");   /// clears or removes current image
        $('#slideshowpic').attr('src',"/uploads/" + $(this).attr('id') + ".jpg");
});

Here, the image which is to be loaded in the main div after clicking thumbnail, is progressive image which is interlanced with php gd.

This is working perfectly in firefox. After clicking thumbnail, the image instantly displays in the main div with progressive fasion. But it doen't seems to be working in chrome.

The Problem is (chrome) : After clicking the thumbnail; first the image is cleared as per the code, then the previous image displays instead of new image (clicked image) and then new image displays after taking some time delay (i think the delay is the time which new image is taking to load).

google chrome doesn't show image till it loads image fully

I just can't figure out where is the problem is. Should i use another technique to load that dynamic image.. ? please help. I stucked in it from many days.

EDIT : you can check it in below links,

Click the thumbnails to load the slideshow.

  • 写回答

3条回答 默认 最新

  • douji5746 2014-10-17 16:34
    关注

    <img> without src has no reason...

    $('.thumb').click( function() {
    
            var img = $('#slideshowpic');
            var src = $(this).attr('id');
    
            img.css('opacity','0').on('load', function() { 
                 $(this).fadeIn();
            }).attr('src',"/uploads/" + src + ".jpg");
    
    
    });
    

    from Detect image load

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?