gpt4 book ai didi

javascript - JS 错误消息 textContent 设置为 null

转载 作者:数据小太阳 更新时间:2023-10-29 05:12:14 24 4
gpt4 key购买 nike

<分区>

我对 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();

我从浏览器收到一条错误消息:

"Uncaught TypeError: Cannot set property 'textContent' of null"... 

我做错了什么?

谢谢!

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com