The example in this article describes the implementation method of javascript non-refresh comments. Share it with everyone for your reference. The specific implementation method is as follows:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无刷新评论</title> <script type="text/javascript"> function AppendComment() { //获取昵称文本框的值 var nicknameValue = document.getElementById("nickName").value; //获取评论文本框的值 var commentValue = document.getElementById("comment").value; var tblComment = document.getElementById("tblComment"); var tr = tblComment.tBodies[0].insertRow(-1); var tdNickName = tr.insertCell(-1); tdNickName.innerHTML = nicknameValue; var tdComment = tr.insertCell(-1); tdComment.innerHTML = commentValue; } </script> </head> <body> 脚本之家<br /> 里面有丰富的脚本教程,欢迎访问 <p>评论</p> <table id="tblComment" border="1"> <tbody> <tr><td>李莫:</td><td>非常好的网站</td></tr> </tbody> </table> 昵称:<input type="text" id="nickName" /><br /> 评论:<textarea id="comment"></textarea><br /> <input type="button" value="评论" onclick="AppendComment()" /> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.