I am trying to create a button for a button in ESP but I want it to be static i.e. if we press the same button there will be an active statement, how to change it?
//html
<button type="button" class="button" onmousedown="toogleLight('light');" ontouchstart="toogleLight('light');" onmouseup="toogleLight('');" ontouchend="toogleLight('');"><img src="assets/img/light.png" /></button>
<script>
function toogleLight(f) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "/" + f, true);
xhr.send();
}
</script>
//esp8266
server.on("/light", HTTP_GET, [] (AsyncWebServerRequest *request) {
Serial.println('f');
request->send(200, "text/plain", "ok");
});