Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<script src=""></script>
<script src="/"></script>
<div id="inputs" style="font-size:60px">
<span>name: </span><input id="username" style="font-size:60px"></input>
<div id="chat" style="font-size:30"></div>
$('#username').change(function () {
var socket = io.connect('http://localhost:8080');
socket.emit('setName', $('#username').val())
$('#inputs').html('<input id="chatinput" style="font-size:60px"></input>').select()
$('#chatinput').select().change(function () {
socket.emit('echo', $('#chatinput').val())
socket.on('echo', function (data, name) {
$('#chat').append('<div><span style="color:blue">['+name+'] </span>'+data+'</div>')
socket.on('join', function (name) {
$('#chat').append('<div style="color:red">'+name+' has joined</div>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.