Why JS function name conflicts with element ID?

后端 未结 3 961
失恋的感觉
失恋的感觉 2020-11-22 06:19

I\'ve got two almost identical simple JS fiddles calling a function on select change. Function name is the same as select ID in both cases, but for some reason the first fid

3条回答
  •  太阳男子
    2020-11-22 06:45

    http://jsfiddle.net/x79ey/1/

    It looks to me like the form tag creates an additional scope around inline event handlers, and form elements are defined as variables in this local scope:

    No variables are auto-defined globally in my tests, but this may vary across browsers/modes.

提交回复
热议问题