We would like to know how to check node type.
<!DOCTYPE html>
<html>
<body>
<p id="amount">
<span></span>
</p><!--from w w w . ja va2 s .c om-->
<script type='text/javascript'>
var amount = document.getElementById('amount'),
text = 'new text';
console.log(amount.firstChild.nodeType);
</script>
</body>
</html>
The code above is rendered as follows: