我在准备好的函数中定义了以下内容
js13(document).ready(function ($) {
var socket = io.connect('http://xx.xx.xxx.xx:8080');
socket.on('connect', function(){
socket.emit('adduser', 'username');
});
socket.on('updatechat', function (username, data) {
data = data.replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """);
js13("#chatboxcontent").append('<div class="ui-chatbox-msg"><b>' + username + ':</b> ' + data + '</div>');
js13("#chatboxcontent").scrollTop(js13("#chatboxcontent")[0].scrollHeight);
});
socket.on('updateusers', function(data) {
$('#users').empty();
$.each(data, function(key, value) {
$('#users').append('<div>' + key + '</div>');
});
});
});
如何在就绪函数之外访问相同的套接字变量?我想从外部函数中访问它