javascript - Can I set a value to the golbal variable in $(document).ready(function(){}); and use the same variable outside? -
suppose, have 1 global variable 'x'
, want set value '2'
i.e. x=2
inside $(document).ready(function(){})
function.
now want use variable 'x'
having value '2'
outside $(document).ready(function(){})
function.
note usage of variable 'x'
after $(document).ready(function(){})
should independent i.e. should not used inside function or callback function.
is possible so? if yes how? if no why?
please provide me detailed solution proper reasons this.
thanks.
note usage of variable 'x' after $(document).ready(function(){}) should independent i.e. should not used inside function or callback function.
if isn't inside function, trying use immediately … before ready
event fires … before value has been assigned variable.
in short: no.
Comments
Post a Comment