I just learned Jquery, My javascript is using the onload event within a function and not an anonimouse function:
window.onload = xFunction;
The problem is when i tryed to use the JQuery ready even, I know i can take the content of xFunction and insert it into anonimouse function:
$("document").ready(function(){
//content of the xFunction.
});
But what i want to do is just supply the function name as the event handler for the jquery ready even:
$("document").ready(function(){
xFunction;
});
//Or
$("document").ready(xFunction);
Both didn’t worked,
My questions are:
-
Is there a way of doing this?
-
Mabye there is but its a bad practice?*
-
Or there isn’t?*
Call the function in
$(document).ready, changexFunctiontoxFunction()Live Demo
or
Live Demo