JavaScript {innerHTML form} that creates a lightbulb picture with (separate) on and off switches

PHOTO EMBED

Tue Jun 06 2023 15:13:37 GMT+0000 (Coordinated Universal Time)

Saved by @Vkmartinez95 #javascript #innerhtml #button #onclick #html

<h2>What Can JavaScript Do?</h2>

<p>JavaScript can change HTML attribute values.</p>

<p>In this case JavaScript changes the value of the src (source) attribute of an image.</p>

<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>

<img id="myImage" src="pic_bulboff.gif" style="width:100px">

<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>
content_copyCOPY

https://www.w3schools.com/Js/tryit.asp?filename=tryjs_intro_lightbulb