JS动态创建评论

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <script type="text/javascript">
        window.onload = function () {
            document.getElementById('id3').onclick = function () {
                var trObject = document.createElement('tr');
                var tdObject1 = document.createElement('td');
                var tdObject2 = document.createElement('td');
                tdObject1.innerHTML = document.getElementById('id1').value+':';
                tdObject2.innerHTML = document.getElementById('id2').value;
                trObject.appendChild(tdObject1);
                trObject.appendChild(tdObject2);
                document.getElementById('tab').appendChild(trObject);
            }
        }
    </script>
</head>
<body>
    <table id="tab"></table>
    昵称:<input type="text" id="id1"><br/>
    <input type="text" id="id2"><input type="button" id="id3" value="评论">
</body>
</html>

评论