Here is an example:
What I want to do is to replace the text in the first paragraph (which is "1") with a string "haha". I tried to use nodeValue to set the text but failed, instead I have to use replaceChild to achieve this. Is it a bug?
<html>
<head>
</head>
<body>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<script type="text/javascript">
var p = document.getElementsByTagName("p")[0];
p.replaceChild(document.createTextNode("haha"), p.firstChild);
//p.firstChild.nodeValue = "haha"; // not working
</script>
</body>
</html>
What I want to do is to replace the text in the first paragraph (which is "1") with a string "haha". I tried to use nodeValue to set the text but failed, instead I have to use replaceChild to achieve this. Is it a bug?