【发布时间】:2016-04-19 06:21:41
【问题描述】:
我正在尝试使用 javascript 将标题动态更改为我的网站,因此标题没有更改。为简单起见,我的 html 看起来像
<div class="container">
<h1 id="name">Nic</h1&g
<p id="email"></p>
<hr>
</div>
<script src="js/something.js"></script>
我的 javascript 位于一个名为 something.js 的文件中,看起来像
$(document).ready(function() {
console.log('I got run');
$('#name').innerHTML = "YO";
$('#email').innerHTML = "why hello";
})
出于某种原因,我在控制台中看到了日志,但 html 从未更改。为什么标题没有改变?
我确实尝试过查看堆栈溢出问题 Javascript: Does not change the div innerHTML 在这里Setting innerHTML: Why won't it update the DOM? 和许多其他人都没有解决我的问题。
【问题讨论】:
标签: javascript jquery html