问题描述
我正在尝试制作 jsfiddle,我的 onclick 在 jsfiddle 中不起作用.我的代码有什么问题
I am trying to make jsfiddle , my onclick is not working in jsfiddle. what is wrong in my code
<input value="press" type="button" onclick="myclick()">
function myclick(){
alert("myclick")
}
http://jsfiddle.net/hiteshbhilai2010/gs6rehnx/11/
我尝试了 No wrap - In head
并再次尝试使用 document.ready
它再次无法在 jsfiddle 中工作
I tried No wrap - In head
and tried again with document.ready
it is not working in jsfiddle again
ERROR - Uncaught ReferenceError: myclick is not defined
http://jsfiddle.net/hiteshbhilai2010/33wLs160/6/
我已经检查了已经存在的问题 here 但我的问题正在发生当我在 jsfiddle 中尝试时
I have checked with already existing question here but my problem is happening when I am trying it in jsfiddle
谁能帮帮我....谢谢
Can some one please help me ....thanks
推荐答案
你需要选择No library (pure JS)和No wrap - in head.然后它将作为带有 javascript 页面的简单 HTML 工作.
You need to select No library (pure JS) and No wrap - in head. Then it will work as a simple HTML with javascript page.
这将被插入到 <head>
的 <script>
元素中:
This will be inserted in a <script>
element in the <head>
:
function myclick(){
alert("myclick")
}
参见演示
这篇关于javascript onclick 在 jsfiddle 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!