Is it correct to create functions inside of
$(document).ready(function() {
like so:
$(document).ready(function() {
function callMe() {
}
});
The function inside of the .ready()
does not have to call before DOM is ready and event inside of the ready()
is triggered.
Just to clarify a little bit - here's the code which would illustrate the problem:
$(function() {
var ind = 0;
// some event is executed and changes the value of the ind
// another event which affects the ind variable
// and another one - after this event we call our function
// there's another event - and we call our function again
The function which I need to call needs the updated value of the ind
variable - which I guess I could pass as a parameter, but is there a better way of doing it?
Also - another important thing is that the function()
in question can also change the value of the ind
variable - for instance incrementing it (ind++
).