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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -