Call function defined inside $(document).ready()
html, javascript, jquery
Solution
$(document).ready(function() {
window.example = function() {
alert("hello")
}
});
Or define it outside, if possible. It doesn't look like it has to be defined inside document ready at all.
Problem
In and external JS file I have ``` $(document).ready(function() { var example = function(){ alert("hello") } }); ``` and I want to call that function from my html, how would I do that? ``` <img src="..." ondblclick="example()" /> ``` n.b. I'm aware of jquery dblclick() but curious about how to correctly do the above.