未捕获的ReferenceError:< function>没有在HTMLButtonElement.onclick中定义 [英] Uncaught ReferenceError: <function> is not defined at HTMLButtonElement.onclick

查看:1569
本文介绍了未捕获的ReferenceError:< function>没有在HTMLButtonElement.onclick中定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https://jsfiddle.net/kgw0x2ng/5/。代码如下:

HTML代码

 < div class =loading>正在载入&#8230;< / div> 
< button type =submitonClick =hideButton()>隐藏< / button>
< button type =submitonClick =showButton()>显示< / button>

JS CODE

  function hideButton(){
$(。loading)。hide();
}
function showButton(){
$(。loading)。show();
}

我正在显示一个微调,并且我希望微调当我点击时隐藏在隐藏按钮上。我收到以下错误:

 未捕获的ReferenceError:showButton没有在HTMLButtonElement.onclick(VM282:180)上定义

onclick @ VM282:180
VM282:179

Uncaught ReferenceError:hideButton未定义
在HTMLButtonElement.onclick(VM282:179)
onclick @ VM282:179。

有人可以提出一个解决方案吗?

谢谢

Sachin

我也有同样的问题......我将所有脚本写入单独的文件,并通过标记将其添加到body标记后面的HTML文件末尾。
在标签内移动标签后,它可以正常工作。
before:

 < / body> 
< script> require('../ script / viewLog.js')< / script>

after:

 <脚本>要求( ../脚本/ viewLog.js')< /脚本> 
< / body>


I have created my problem on JSFiddle at https://jsfiddle.net/kgw0x2ng/5/. The code is as follows

HTML CODE

<div class="loading">Loading&#8230;</div> 
<button type="submit" onClick="hideButton()">Hide</button>
<button type="submit" onClick="showButton()">Show</button>

JS CODE

function hideButton(){
   $(".loading").hide();
}
function showButton(){
   $(".loading").show();
}

I am showing a spinner and I would like the spinner to hide when I click on the "Hide" button. I am getting the following error :

Uncaught ReferenceError: showButton is not defined
    at HTMLButtonElement.onclick (VM282:180)
onclick @ VM282:180
VM282:179  

Uncaught ReferenceError: hideButton is not defined
    at HTMLButtonElement.onclick (VM282:179)
onclick @ VM282:179.

Can someone please suggest a solution?

Thanks

Sachin

解决方案

Same Problem I had... I was writing all the script in a seperate file and was adding it through tag into the end of the HTML file after body tag. After moving the the tag inside the body tag it works fine. before :

</body>
<script>require('../script/viewLog.js')</script>

after :

<script>require('../script/viewLog.js')</script>
</body>

这篇关于未捕获的ReferenceError:&lt; function&gt;没有在HTMLButtonElement.onclick中定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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