image zoom at hover on a text
Hello,
I have a web application, I have some <a> tags (at a div at left of page), and some images that each tag has it's specified image. (images are at a div at the right of page). when I mouse over on each tag I want the specific image to zoom and other image's opacity become lower.
HTML code:
- <div id="right" style="width:40%; height:500px; float:left;">
- <a href="#">imge1</a>
- <a href="#">imge2</a>
- <a href="#">imge3</a>
- <a href="#">imge4</a>
-
- </div>
- <div id="left" style="width:60%; height:500px; float:right;">
- <img class="img" src="1.jpg""/>
- <img class="img" src="2.jpg" />
- <img class="img" src="3.jpg" />
- <img class="img" src="4.jpg" />
-
- </div>
I don't know how can I do that, I used the below js code but it doesn't work. I'm not familier with js. but need this code, please help.
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- var cont_left = $("#container").position().left;
- $("a").hover(function () {
- // hover in
- $(img).parent().parent().css("z-index", 1);
- $(img).animate({
- height: "250",
- width: "250",
- left: "-=50",
- top: "-=50"
- }, "fast");
- }, function () {
- // hover out
- $(img).parent().parent().css("z-index", 0);
- $(img).animate({
- height: "150",
- width: "150",
- left: "+=50",
- top: "+=50"
- }, "fast");
- });
- $(".img").each(function (index) {
- var left = (index * 160) + cont_left;
- $(img).css("left", left + "px");
- });
- });
- $(function () {
- $('.img').each(function () {
- $(this).hover(
- function () {
- $(this).stop().animate({ opacity: 1.0 }, 800);
- },
- function () {
- $(this).stop().animate({ opacity: 0.3 }, 800);
- })
- });
- });
- </script>