我对JS和Web开发世界都很陌生,所以如果我的问题有点乏味,请提前道歉.
我写了这段代码:
var breakfast = new Object();
breakfast.food = "croissant";
breakfast.extra = ["mushroom", "cheese"];
breakfast.eat = function(){return this.food + " with " + this.extra[0];}
var elBreakfast = document.getElementById("breakf");
elBreakfast.textContent = breakfast.eat();
Run Code Online (Sandbox Code Playgroud)
我从浏览器收到错误消息:
"Uncaught TypeError: Cannot set property 'textContent' of null"...
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
谢谢!
javascript ×1