events - Javascript closures problem -


I have some legacy JS code that uses this format:

  function Main (the best) {var myVar; Function doSomething () {...} .... doSomething (); ....}   

This works, but now I have to control some click events. Something like this: Function Main (Ultimate) {var myVar; Function manageEvent (item) {... myVar = item.value; ...} .... item.onclick = function () {manageEvent (this)}}}

The problem is that there is no access to manageEvent () / Strong> myVar and I do not know how to rewrite all code to solve the problem (really hard). myVar ? How can I manage events to give access to "manageEvent" for

?

This works:

Your problem is elsewhere, it is definitely not in this code; Try it perfectly fine and see what exactly the click is the same value; Try and play with its value and see the results but anyway, your post code works, and without any further information, we can not really find what is wrong in your situation.

Comments