"typed"中有我正在尝试编辑和更改的代码。在"类型化"中,存在与项目不一致的代码。
setTimeout(function() {
document.querySelector('.typed').innerHTML = 'Goodbye World'; // <- this is what changes the content inside the HTML
}, 2000);
<span class="typed">Hello World</span>
使用 setTimeout 只是为了向内容更改添加延迟以显示它有效。
按类定位元素是危险的,但如果有超过 1 个元素使用该类。最好改用 id。