Nishant is correct for the mouseout, you are just missing the first single quote.
For the style you would probably want something like this
<style media="screen" type="text/css">
.pop-up {
height: 200px;
width: 100px;
margin-right: 100px;
margin-top: -10px;
position:absolute;
right:50px;
top:50px;
}
</style>
The position: absolute; will tell the browser to put it exactly where you want it. In this example I told it to position itself 50px from the top and 50px from the right. You can also use the keywords "bottom" and "left".
Answer from Developer Gee on Stack Overflowjavascript - Position popup image on mouseover - Stack Overflow
tags (instead of the just the one, (listed on the help page linked above) in var pathToImage? < script type = "text/javascript...
More on stackoverflow.comgallery - Javascript image popup on mouseover on thumbnail of said image - Stack Overflow
Trying to show image in popup box when I hover over a button - HTML & CSS - SitePoint Forums | Web Development & Design Community
Pop up image on mouse over - Highcharts official support forum
Nishant is correct for the mouseout, you are just missing the first single quote.
For the style you would probably want something like this
<style media="screen" type="text/css">
.pop-up {
height: 200px;
width: 100px;
margin-right: 100px;
margin-top: -10px;
position:absolute;
right:50px;
top:50px;
}
</style>
The position: absolute; will tell the browser to put it exactly where you want it. In this example I told it to position itself 50px from the top and 50px from the right. You can also use the keywords "bottom" and "left".
Here try this...
CSS
<style>
.pop-up {
height: 200px;
width: 100px;
margin-right: 100px;
margin-top: 10px;
float: right;
display:none;
}
.button {
/*change the width and height to match button.jpg's*/
width:50px;
height:50px;
display:block;
background-image:url(image/button.jpg);
}
</style>
HTML
<a href="" class="button" onmouseover="javascript:ShowImage('images/eco.jpg')" onmouseout="javascript:HideImage()"></a>
<div id="popup" class="pop-up">
<img id="popupImage" alt="Popup image" />
</div>
JavaScript
<script type="text/javascript">
function ShowImage(src)
{
var img = document.getElementById('popupImage');
var div = document.getElementById('popup');
img.src = src;
div.style.display = "block";
}
function HideImage()
{
document.getElementById('popup').style.display = "none";
}
</script>
hope this helps.
Here's a quick way to do it.
http://jsfiddle.net/wilchow/4hzenxkh/
HTML:
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 1</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 2</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 3</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 4</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 5</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 6</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 7</a></p>
<p class="product"><a href="#"><img src="http://placehold.it/64/64" alt=""/>test 8</a></p>
CSS:
p.product a img {
display: none;
position: absolute;
left: -80px;
top: -22px;
}
p.product a {
display: inline-block;
position: relative;
}
p.product {
margin-left: 150px;
}
script:
$(document).ready(function() {
$(".product a").mouseover(function () {
$(".product a img").css("display", "none"); // hide all product images
$(this).find("img").css("display", "inline-block"); // show current hover image
})
$(".product a").mouseout(function () {
$(".product a img").css("display", "none"); // hide all product images
})
});
That site is doing it with css:
HTML
<td align="left" valign="top" class="alpha-list">
<p class="mainline PA_product"><a href="/products/connectors/PA.asp"><span>
<img src="/graphics/products/small/PA-PAHD-HPAHD3.gif" width="73" height="80" border="0">
</span>PA Holdown </a></p>
...
</td>
CSS
td.alpha-list A:hover span img {
border: 1px solid #DDDDDD;
padding: 2px;
display: block;
position: absolute;
left: -90px;
top: -25px;
z-index: 102;
background-color: #FFFFFF;
}
It basically just displays the image on hover and then uses CSS for positioning.
TIP Use the chrome dev tools to inspect something like this.
- Use the "select element" tool to choose one of the links
- Select the "elements" tab
- Under "styles" click the "toggle element state" icon and choose ":hover" - this puts the link in a hover state
- Now you can select the pop-up image element to inspect the CSS used for styling
Hope this helps
Actually to show this, you don't need jQuery at all, since you can do it just with css as here: http://jsfiddle.net/wwp66o9s/1/
<ul>
<li>
<a href="javascript:void(0)">
This is some link
<img src=http://lorempixel.com/400/200/>
</a>
</li>
<li>
<a href="javascript:void(0)">
This is some link
<img src=http://lorempixel.com/400/200/>
</a>
</li>
<li>
<a href="javascript:void(0)">
This is some link
<img src=http://lorempixel.com/400/200/>
</a>
</li>
</ul>
li {
list-style: none;
position: relative;
}
li a > img {
display: none;
position: absolute;
top: 10px;
left: 150px;
}
li a:hover > img {
display: block;
}
here link is the class name on which it is hover
$(".link").mouseover(funtion(){
var imagepath = $(this).attr("data-target")
$( "this").tooltip({ content: "<img src='"+imagepath+"'/>" });
})
From you original question and this comment ("Hello, thanks for the reply. The image needs to pop up over the div about the mouse point. Moving the mouse changes the image location to where the mouse is. Thanks though!")
I created this solution:
http://jsfiddle.net/YPu96/1/
Hover over div: The image becomes visible and follows the mouse-pointer.
On click: The image becomes invisible and stops following.
HTML:
<div class="someDiv">
<p>Foobar</p>
</div>
<img style="display:none" class="image" src="http://www.budick.eu/images/logo-BudickEu.jpg"/>
JavaScript:
$(".someDiv").hover(function() {
$(document).mousemove(function(event) {
$(".image").css({"position":"absolute","left":event.clientX ,"top":event.clientY }).show();
});
});
//end movement with click
$(document).bind("click",function(){
$(document).unbind("mousemove");
$(".image").hide();
});
You definitely don't need to use javascript. This works on the latest version of Chrome, use vendor prefixing for transitions.
http://jsfiddle.net/pKYu2/16/
HTML
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<span id="mouseOver"><img src="http://placekitten.com/120/120">Mouse Over This</span>
</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
CSS
#mouseOver {
display: inline;
position: relative;
}
#mouseOver img {
position: absolute;
left: 50%;
transform: translate(-50%);
bottom: 1em;
opacity: 0;
pointer-events: none;
transition-duration: 800ms;
}
#mouseOver:hover img {
opacity: 1;
transition-duration: 400ms;
}
html code:
<a href="#">some text here..<img src="image url" /></a>
css code:
a img { display:none; }
a:hover img { display:block; }
$("#selectable li").mouseover(function(){
$(this).next().show();
});
$("#selectable li").mouseout(function(){
$(this).next().hide();
});
you can try this
I could imagine something like this here:
$(".image").hover(function(){
//display bigger image here
}, function() {
//hide it here
});
Alternative, you can use CSS :hover
Yes it is possible.
With JQuery mouseover event : http://api.jquery.com/mouseover/
And a popup plugin like magnific popup : http://dimsemenov.com/plugins/magnific-popup/
For displaying images next to cursor you can use this one jQuery method
$(document).mousemove();
Example:
$(document).mousemove(function(e) {
$('.logo').offset({
left: e.pageX,
top: e.pageY + 20
});
});
See this fiddle for the working one https://jsfiddle.net/q1xc7vbg/
Cheers
For hover-zoom take a look here.
I hope i got you right now. When the mouse hovers the image (mouseover-event), you have to create and append a new element containing the image to the body. This should not be positioned over the original image in order to not trigger the mouseleave event immediately. Later on, when the user moves his mouse out of the small image, you can delete/remove the created element when the mouseleave-event triggers.
I would recommend to use an absolute positioning on the big-image element.