javascript onclick 在 jsfiddle 中不起作用 [英] javascript onclick not working in jsfiddle

查看:16
本文介绍了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 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆