我在 jsfiddle/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 jsfiddle/kgw0x2ng/5/. The code is as follows
HTML CODE
<div class="loading">Loading…</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:< function>没有在HTMLButtonElement.onclick中定义
发布评论