For some reason JavaScript doesn\'t seem to recognise my function.
I have a button in some HTML:
Try this:
var lightOn = function(){
}
And you can do all of this in vanilla JS instead of using jQuery too:
var lightOn = function(){
document.getElementById('lightOn').className += " active";
document.getElementById('lightOff').className.replace(/\bactive\b/,'');
socket.emit("setting", {"light":"on"});
}
A good explanation for var lightOn = function()
and function lightOn()
can be found here: https://stackoverflow.com/a/336868/1887101