Learn free online HTML5, javascript, and jquery Tutorials by Examples

Monday 19 January 2015

On hover image Change in jQuery

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Image Change</title>
<script src="js/jquery.js"></script>
</head>
<body>
<style>
li{float:left; margin:2px; position:relative;}
.repl {position: absolute;top: 0;}
</style>
<div class="blog">
  <ul>
    <li><img src="portfolio_1.jpg" width="200" height="200" />
        <div class="repl">
            <img src="portfolio_2.jpg" width="200" height="200" />
        </div>
    </li>
    <li><img src="portfolio_2.jpg" width="200" height="200" />
            <div class="repl">
                <img src="portfolio_3.jpg" width="200" height="200" />
            </div>
    </li>
    <li><img src="portfolio_3.jpg" width="200" height="200" />
            <div class="repl">
                <img src="portfolio_1.jpg" width="200" height="200" />
            </div>
    </li>
  </ul>
</div>
<script>
    $(window).load(function(){
    $('.blog').children('.repl').hide();
});
    $(document).ready(function(){
        $('ul li').children('.repl').hide();
        $('ul li').mouseover(function(){
           $(this).children('.repl').show();
        });
        $('ul li').mouseout(function(){
             $(this).children('.repl').hide();
         });
    });
</script>
</body>
</html>

No comments:

Post a Comment