Имею вот такую ошибку
Uncaught TypeError: Cannot read property 'scrollHeight' of null
at Socket. (chat:55)
at Socket.Emitter.emit (socket.io-1.2.0.js:1)
at Socket.onevent (socket.io-1.2.0.js:1)
at Socket.onpacket (socket.io-1.2.0.js:1)
at Manager. (socket.io-1.2.0.js:1)
at Manager.Emitter.emit (socket.io-1.2.0.js:1)
at Manager.ondecoded (socket.io-1.2.0.js:1)
at Decoder. (socket.io-1.2.0.js:1)
at Decoder.Emitter.emit (socket.io-1.2.0.js:1)
at Decoder.add (socket.io-1.2.0.js:3)
Вот код
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Сайт по ифнорматике </title>
<link rel="stylesheet" href="/css/Main.css">
</head>
<body>
<header>
<div class = "line">
<div class = "head">
<nav>
<ul class = "menu">
<li>
<a href="http://laptop-6dan5qsf:3000/">Главная</a>
</li>
<li>
<a href="http://laptop-6dan5qsf:3000/video">Видео</a>
</li>
<li>
<a href="http://laptop-6dan5qsf:3000/chat">Чат</a>
</li>
<li>
<a href="http://laptop-6dan5qsf:3000/photo">Фото</a>
</li>
</ul>
</nav>
</div>
</div>
</header>
<div class="box4">
<div class="mmm">
<ul id="messages"></ul>
<form action="">
<input id="m" autocomplete="off" /><button>Send</button>
</form>
</div>
</div>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.js"></script>
<script>
$(function () {
var socket = io();
$('form').submit(function(){
socket.emit('chat message', $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg){
$('#messages').append($('<li>').text(msg));
const el = document.querySelector('box4');
console.log(el.scrollHeight);
window.scrollTo(0, el.scrollHeight);
});
});
</script>
</script>
<script>
</script>
</div>
</body>
</html>