javascript - call function inside $ (function () {...}) jquery -


call function inside $ (function () {...})

example:

$ (function () {      makealert function (text) {          alert (text)       }  });  

i want call "makealert" function block.

makealert call () not work.

please help!

you can't. you've scoped function function declared within.

move outside global. there no need delay definition until ready event fires.


alternatively, create global reference within outer function.

window.makealert = makealert; 

it wouldn't recommend unless have other reason keep function being declared until ready event fires more complicated.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -