Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (40 sloc) 1.26 KB
<!DOCTYPE html>
<html lang="en-US">
<meta charset="utf-8">
<title>Mouse and keyboard events example</title>
.thumb {
width: 100px;
.zoom {
position: absolute;
<h1>Mouse and keyboard events example</h1>
<img class="thumb" src="pirate.jpg" tabindex="0" alt="A lego pirate figure with a cutlass, pistol, tricornered hat, peg leg, long hair and beard.">
var imgThumb = document.querySelector('.thumb');
imgThumb.onmouseover = showImg;
imgThumb.onmouseout = hideImg;
imgThumb.onfocus = showImg;
imgThumb.onblur = hideImg;
function showImg() {
var imgZoom = document.createElement('img');
var widthOffset = imgThumb.x + imgThumb.width + 10; = widthOffset + 'px';
var heightOffset = imgThumb.y; = heightOffset + 'px';
function hideImg() {
var imgZoom = document.querySelector('.zoom');
You can’t perform that action at this time.