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

查看:107
本文介绍了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/

我已经检查了已经存在的问题此处,但是我的问题正在发生当我在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

推荐答案

您需要选择无库(纯JS)无包装-.然后它将作为带有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天全站免登陆