-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex-2.html
More file actions
40 lines (40 loc) · 1.07 KB
/
index-2.html
File metadata and controls
40 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html>
<head>
<title>Socket Web Chat</title>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<h1>Socket Chat</h1>
<div class="nickname-box">
<input id="nickname"/>
</div>
<div id="chat-box">
<ul id="messages">
</ul>
<form action="">
<input id="m" autocomplete="off"/>
<button>Send</button>
</form>
</div>
<script src="socket.io.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(function() {
var socket = io();
$('form').submit(function(e){
e.preventDefault();
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$("#messages").append($('<li>').text(msg));
});
});
</script>
</body>
</html>