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

php - How to serve a file for download on WordPress -

how to share virtual sharepoint server and get it in host windows and visual studio? -