Wednesday, 28 December 2011

How to enlarge image on mouseover in asp.net using jquery


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Img_Enlarge.aspx.cs" Inherits="Img_Enlarge" %>


<!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 id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <style type="text/css">
        .thumbnail
        {
            height: 100px;
            width: 100px;
            position: relative;
        }
        .image
        {
            position: relative;
            width: 400px;
            height: 250px;
        }
    </style>
    <script language="javascript" type="text/javascript">
        $(document).ready(function () {
            $(".thumbnail").mouseover(function () {
                $(".thumbnail").css("opacity", ".5");
                $(this).animate({ opacity: 1.0 });
                $("#imgContainer").append("<img class='image' src='" + $(this).attr("src") + "' />");


            });
            $(".thumbnail").mouseout(function () {
                $(".thumbnail").css("opacity", "1.0");
                $(".image").remove();
            });
        });
       
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
    <div align="center">
        <img alt="" class="thumbnail" src="Image/Chrysanthemum.jpg"/>
        <img class="thumbnail" src="Image/Desert.jpg" alt="" />
        <img class="thumbnail" src="Image/Hydrangeas.jpg" alt="" />
        <img class="thumbnail" src="Image/Jellyfish.jpg" alt="" />
        <div id="imgContainer">
        </div>
    </div>
</body>
</html>







No comments:

Post a Comment