Why not just define the function? function msg() { alert("Hello User"); }
If you do that, it'll be available when the DOM is loaded ie. $(document).ready() On Thu, Feb 19, 2009 at 1:17 AM, JQueryProgrammer <jain.ashis...@gmail.com> wrote: > > Got it. I need to define as > > (function() { > msg = function() { > alert("Hello User"); > } > > })(); > > Thats it. > > On Feb 19, 11:08 am, JQueryProgrammer <jain.ashis...@gmail.com> wrote: >> How can we define functions even before the DOM loads fully. I tried >> like >> >> (function() { >> msg = function() { >> alert("Hello User"); >> } >> >> }); >> >> $(function() { >> msg(); >> >> }); >> >> This is just an example. But it gives me "Object Expected" error. >> Please let me know how to do it.