Forum Documentation

Javascript problem: nodeValue property not working

neodreamer
Here is an example:

<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?
mikeday
Yes, this should be fixed in Prince 8.1, along with support for the textContent property.