I have a DHT sensor and I used mqtt to send data to server. From there I displayed the data to a span
, so the span value is changing.
What I want to do is:
When sensor stop working, it will display fault in that span
and I want to display image only when its fault.
<span id="fault"></span>
i tried to use JS to get the span
then display image but its not working
<img src="yellowled.png" alt="Girl in a jacket" width="60" height="60" id="my_image">
<script>
document.getElementById('my_image').style.display = 'none';
var span_Text = document.getElementById("fault").innerText;
if (span_Text === "fault"){
document.getElementById('my_image').style.display = 'inline';
}
</script>