i know this question is old but i think this short example could help others as well.
I would access the element by its ID and change the innerText.
HMTL-Client side:
function buttonSendStringFromInput(){ var string = document.getElementById("inputfield").innerText; socket.emit("getStringfromHTML", string); }2.Node Express-Server side:
socket.on("getStringfromHTML", (string) => { console.log(string);
// string changes var stringNew = ....
socket.emit("getNewString", stringNew); // Your client re-render without page reload
socket.broadcast.emit("getNewString", stringNew); // Re-render for all clients who are conntected to your page });
socket.on("getNewString", (string) => { console.log(string); document.getElementById("inputfield").innerText = string; });
There is no need to reload the page :)