I am calling javascript function from html. But it keeps return error and saying function is not defined in jsfiddle.
here is html code
<div id="Container">
<img alt="Click to zoom" class="image" onclick="resizeImg(this)"
src="http://www.extremetech.com/wp-content/uploads/2012/12/Audi-A1.jpg" />
</div>
here is javascript
function resizeImg (img) {
var resize = 150; // resize amount in percentage
var origH = 61; // original image height
var origW = 250; // original image width
var mouseX = event.x;
var mouseY = event.y;
var newH = origH * (resize / 100);
var newW = origW * (resize / 100);
// Set the new width and height
img.style.height = newH;
img.style.width = newW;
var c = img.parentNode;
// Work out the new center
c.scrollLeft = (mouseX * (resize / 100)) - (newW / 2) / 2;
c.scrollTop = (mouseY * (resize / 100)) - (newH / 2) / 2;
}
Why and how to solve it?
onDomready, so your function isn't declared globally