On Fri, Oct 24, 2008 at 2:25 PM, Eric P <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to mix jQuery with some pre-existing JavaScript/HTML, but > I'm having what appears to be scope issues. > > The code I'm working on already has a bunch of inline event handler > function calls in the HTML tags, and it'd be a ton of work to change > them all to the unobtrusive way via jQuery. Now when I wrap all the > pre-existing function definitions into the jQuery document instance > (i.e., $(function(){ ... }), I'm able to slip in some jQuery. > However, all the function definitions are now no longer available to > the inline event handler calls. > > Here's a simple demonstration. In this example the test() function is > not available when the div. > > <script> > $(function(){ > function test(){ console.log('hi')} > }); > </script> > > <div onclick="test()" style="background-color:red; width:300px">hi </div> >
Opps... small typo. "In this example the test() function is not available when the div" ...is clicked.