Why isn't my JavaScript working in JSFiddle?

前端 未结 7 1342
萌比男神i
萌比男神i 2020-11-21 05:11

I can\'t find out what is the problem with this JSFiddle.

HTML:


Jav

7条回答
  •  一整个雨季
    2020-11-21 05:25

    If you do not specify the wrap setting it defaults to "onLoad". This results with all JavaScript being wrapped in a function run after result has been loaded. All variables are local to this function thus unavailable in the global scope.

    Change the wrapping setting to "no wrap" and it'll work:

    http://jsfiddle.net/zalun/Yazpj/1/

    I switched the framework to "No Library" as you don't use any.

提交回复
热议问题