undefined不是函数! [英] undefined is not a function !

查看:101
本文介绍了undefined不是函数!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个.js文件

当我在另一个页面调用函数ehsan11()时得到此错误:未捕获TypeError:undefined不是函数(索引) ):1 onclick



我在按钮onclick中使用:

hi
I have a .js file
when i call function ehsan11() in another page get this Error : Uncaught TypeError: undefined is not a function(index):1 onclick

Im use in in Button onclick :

<button style="width:250px;" id="sendaccept" class="sendaccept" onclick="ehsan11();">send accept</button>





**当我在这个.js文件中创建一个函数时我可以调用!但我不能打电话给这个

现在我的Fubktion在.js文件中



你可以看到我的班级听到:点击

推荐答案

要从您的标记调用任何JavaScript函数,该函数必须显示在您的页面中其中一种方式:

1.成为脚本块中页面的一部分

2.使用带有src属性的脚本块链接到您的页面

如果您没有执行其中任何一项,您将收到未定义错误,因为页面无法找到您的功能...

https://developer.mozilla.org/en/docs/Web/HTML/Element/script [ ^ ]
To call any JavaScript function from your markup, that function must be presented in your page in one of these ways:
1. Be part of the page inside a script block
2. To be linked to your page using script block with src attribute
If you do not do one of these you will get an 'undefined' error as the page can not find your function...
https://developer.mozilla.org/en/docs/Web/HTML/Element/script[^]


这篇关于undefined不是函数!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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