Onclick event not firing on jsfiddle.net [closed]

2019-01-03 03:38发布

I'm testing some javascript on jsfiddle and for some reason I can't get a function to fire on a button click. Any advice?

jsfiddle link

2条回答
Lonely孤独者°
2楼-- · 2019-01-03 03:50

You have configured JSFiddle to wrap the code in an onload event handler. Consequently the function you are trying to call onclick is out of scope.

Don't use intrinsic event attributes. Use jQuery's (since you are using jQuery already) event binding instead.

查看更多
beautiful°
3楼-- · 2019-01-03 04:08

In the Frameworks & Extensions panel, set onLoad to No wrap - in <body>.

It took me a while to figure this out.

查看更多
登录 后发表回答