jquery - Trying to add a click function to an image, makes the image disappear -


i'm trying practice jquery events , want click through pictures while having on click event, work multiple effects.

currently, have image grows when hovered over, , shrinks when mousedout.
works until uncomment commented code in jquery. image disappears. have tried think of, , i'm not sure went wrong.
i'm new jquery , i'm teaching myself via tutorials , source code other projects, wouldn't doubt if stupid on part.
appreciate if me solve problem. bug fixing seems weakest part of coding, far.

    $(document).ready(function() {         var preloadimgs = ['imgs/ptilota.jpg',                            'imgs/cell_division.jpg',                            'imgs/lynx_spiders.jpg'];          var imgs = [];         (var i=0; i<preloadimgs.length; i++) {             imgs[i] = new image();             imgs[i].src = preloadimgs[i];         }          var photo = $('#photo');         var imgval = 0;          photo.attr('src',preloadimgs[imgval]);          photo.hover(             function() {                 $(this).stop().animate(                     {                         width: '1080px',                         height: '682px'                     }, 500                 );             },              function() {                 $(this).stop().animate(                     {                         width: '540px',                         height: '341px'                     }, 500                 );             }         );          /* photo.click(              function() {                 imgval = imgval + 1;                   if (imgval >= preloadimgs.length) {                     imgval = 0;                 }                   photo.attr('src',preloadimgs[imgval]);             }         ); */      }); 

this html:

<body>  <img src="" id="photo" />  </body> 


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -