You can either move the function declaration outside the DOM-ready handler:
function example(){ alert("hello") }
$(document).ready(function() {
});
But the best solution is to save JavaScript in your .js files and to exclude built-in event handlers. Give the element an identifier and enter it:
<img src="..." id="imgid" />
$(document).ready(function() {
document.getElementById("imgid").ondblclick = function(){ alert("hello") }
});
source
share