Hi,

In one of my web page When user clicks a thumbnail view of my page then the main Image will show that corresponding

My code as followa

jQuery('products li img').click(function(){

var as=jQuery(this).attr('href');

jQuery('#mainImg').attr('src',as)
});


My doubt is at the time of user clicks on that thumb a small preload will need to show ... Please help

Thanks in advance
:)

This will preload all the images, so they will stand a reasonable chance of being in browser cache when user clicks each thumbnail:

...
  var img, mainImg = jQuery('#mainImg').get(0);
  jQuery('products li img').each(function(){//loop to preload images immediately
    img = new Image();
    img.src = this.href;
  }).click(function(){//establish onclick handler
    mainImg.src = this.href;
  });
...

untested

Make sure it's all wrapped in window.onload = function(){...}; or jQuery(document).ready(function(){...}); or similar.

Airshow

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.