</form>
</p>
+ <p>
+ <form action="" id="comment-form">
+ <input id="comment" type="text" style="width:100%" autocomplete="off" placeholder="Add a comment" />
+ </form>
+ </p>
+
<div align="center">
<div class="animate-flicker">
<p>
<script src="/socket.io/socket.io.js"></script>
<script>
var socket = io();
+
+ var form = document.querySelector("#comment-form");
+ var comment = document.querySelector("#comment");
+
+ form.addEventListener('submit', function(e) {
+ e.preventDefault();
+ if (comment.value) {
+ socket.emit('comment', comment.value);
+ comment.value = '';
+ }
+ });
</script>
</body>
</html>