Pass element ID to Javascript function

后端 未结 5 1157
南旧
南旧 2020-12-01 16:37

I have seen many threads related to my question title.

Here is HTML Codes :

5条回答
  •  -上瘾入骨i
    2020-12-01 16:57

    In jsFiddle by default the code you type into the script block is wrapped in a function executed on window.onload:

    
    

    Because of this, your function myFunc is not in the global scope so is not available to your html buttons. By changing the option to No-wrap in as Sergio suggests your code isn't wrapped:

    
    

    and so the function is in the global scope and available to your html buttons.

提交回复
热议问题