Now the element variable stands for what's in  document.getElementById("messages").

Make sure to pick element, followed by document.getElementById, and finally "messages".