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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -