jQuery HTML Element How to - Click to show image








Question

We would like to know how to click to show image.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){<!--   ww  w  .  ja  v a  2  s  .c  o  m-->
    $('img').click(function() {
        $(this).attr('src', 'http://www.java2s.com/style/download.png');
    });
});
</script>
</head>
<body>
  <div id="slideshow">
    <img class="one" alt="Slide" id="slideShow" />
  </div>
</body>
</html>

The code above is rendered as follows: