I set the following in my console:
document.getElementById('messsages').textContent;
which gave me the output "this is a message i sent through websocket chat!"
I then did
var convo = document.getElementById('messsages').textContent;
and typed in convo into the console and it gave me the same output as before. I then sent another message through my websocket chat and typed in convo and it gave me the old output but when I typed in document.getElementById('messsages').textContent; it gave me the new output.
Why is this? And is there a method for me to assign a variable which updates its value accordingly with my element?
document.getElementById('messsages').textContentin your case.var convo = { set title(text) { document.getElementById('messsages').textContent = document.title = text; } };