Skip to content Skip to sidebar Skip to footer

Jquery Hover A Div And Display Image On Another Div With Effect

OK javascript newbie here, I want help! Here is the design that explains better the situation. My JSFiddle Here My Code:

Solution 1:

Here is a quick demo that will get you started:

Demo:jsFiddle

As you can see I'm using a list with data attributes to set which image should be displayed ( <li data-image='image.jpg'><a ...></a></li>) - the rest is handled by JS.

To control the behavior change the variables value as needed:

var imageContainer = '.img_container', //selector of the image container
    imageList      = '.hoverimage',     //selector of the image list
    maxWidth       = 'parent',          //parent or specific CSS width. 
    defImage       = 'image_to_display.jpg';

Solution 2:

JSFiddle: http://jsfiddle.net/r6ywtk6u/

You will need to put a source for the images

Jquery:

$("a").hover(function(){
    $(".zoom-preview").html($(this).html());
  },
  function() {
    $( ".zoom-preview" ).html( "image will appear here when we hover at each link at the left. each link it's own image. Also there must be a default image here when we do not hover at any link at the left." );
  });

HTML:

<divclass="design"><divclass="menu">5 menu options will be in this div and when we hover at each link an image must appear to the right with fast zoom in effect like shooting.
           <liclass="menu-item"><ahref="#"><imgalt="foo"/></a></li><liclass="menu-item"><ahref="#"><imgalt="bar"/></a></li><liclass="menu-item"><ahref="#"><imgalt="bam"/></a></li><liclass="menu-item"><ahref="#"><imgalt="baz"/></a></li><liclass="menu-item"><ahref="#"><imgalt="quux"/></a></li></div><divclass="zoom-preview"> 
       original content
       </div><divclass="clear"></div></div>

on hover enter, you take the html inside the link and put it in the display box. when it leaves, you put the original content back.

Post a Comment for "Jquery Hover A Div And Display Image On Another Div With Effect"