我是 Javascript 的初学者,这是我在 Stackoverflow 上的第一篇文章。我按照一本书来玩一些javascript函数。在这里,我通过 innerHtml 方法存储。它应该可以工作,但事实并非如此。我看了不同的地方,无法弄清楚原因。请帮忙。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<a href = "popupA.html" id = "link">Link</a>
<p id = "p1">paragraph 1</p>
<p id = "p2">paragraph 2</p>
<script>
document.getElementById('link').href = 'popupB.html'; //works
document.getElementById('p1').innerText = 'sample1'; //works
var a = document.getElementById('p2');
a.innerHtml = "sample 2"; //innerHtml doesn't work here
</script>
</body>
</html>