document.log():"undefined不是函数”;
document.log(): "undefined is not a function"
我知道,我知道,这是一个常见的错误,你应该看看其他人等等。我已经找到了,但我不可能找到解决方案。
这是我的全部代码。
<div id="div"></div>
<script>
function item(id, price, name, icon){
this.id = id;
this.initPrice = 0;
this.price = price;
this.name = name;
this.icon = icon;
document.getElementById("div").innerHTML += this.name + " = $" + price + " <input id='"itemNum" + this.id + "'" onchange='"item" + this.id + ".calc()'" type='"number'" style='"width: 40px;'" value='"1'"></input><br>";
this.calc = function(){
document.log("yay");
}
}
var item1 = new item(1, 700, "Barrel #1", "");
item1.calc();
</script>
我在第14行得到错误,当我改变输入时,我在第十四行再次得到相同的错误。我做错了什么?我该怎么解决这个问题?
您需要使用:
console.log("yay");
而不是:
document.log("yay");
Fiddle演示
尝试console.log()
而不是document.log()
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 为什么会出现错误,“UncaughtTypeError:undefined不是函数”
- mongoose.connect undefined不是一个函数
- Uncaught TypeError:undefined不是函数-ember js
- jQuery Mobile Undefined不是一个函数
- 未捕获的类型错误:undefined不是函数$
- 使用在函数外部声明的变量的 Javascript 返回值 + undefined
- 为什么Grunt Copy给了我一个'undefined不是函数'警告
- Bootstrap-“;未捕获的类型错误:undefined不是函数;
- Undefined不是函数ImpressPages DatePicker
- 尝试使用.ninnerHTMLlog打印数据,获取错误Uncaught TypeError:undefined不是函数
- 得到“;undefined不是函数“;错误
- Undefined不是Fullcalendar js上的函数
- 使用谷歌地图:一个返回undefined的自定义javascript函数
- jqGrid:undefined不是函数
- Jquery,Uncaught TypeError:undefined不是函数
- $http.post undefined 不是函数
- Ember cli Uncatch TypeError: undefined 不是函数
- Infragistics igGrid Uncatch TypeError: undefined 不是一个函数
- JQuery脚本在Firefox上工作;undefined不是函数“;铬