javascript onclick not working in jsfiddle(javascript onclick 在 jsfiddle 中不起作用)
问题描述
我正在尝试制作 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 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:javascript onclick 在 jsfiddle 中不起作用


基础教程推荐
- Bokeh Div文本对齐 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01