Loading ...
Sorry, an error occurred while loading the content.

156Re: Be careful when making functions in a loop...

Expand Messages
  • Douglas Crockford
    Aug 13, 2008
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Ben Collver" <tylx@...> wrote:
      > I wrote an example script and it appears to bind to the current value
      > of the variable "i". The script is at the following URL.

      > If you please would you show an example of the problem?

      Create a page with three buttons, a, b, and c. When you click on a
      button, it alerts its number. Modify your loop to get each element by
      id and attach an onclick handler that alerts the index. If you do it
      incorrectly, they will all alert the same wrong number.
    • Show all 8 messages in this topic