The Light Bulb using JavaScript
The Light Bulb using JavaScript
Code
<html>
<head>
<title>The Light Bulb</title>
</head>
<body>
<h2> First JavaScript</h2>
<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>
</body>
</html>
Output
![](https://techonespot.com/wp-content/uploads/2022/12/bulb.png)
Try Yourself
![](https://techonespot.com/wp-content/uploads/2022/04/successcc0-.png)
Fun & Easy to follow
![](https://techonespot.com/wp-content/uploads/2022/04/growthcc0-.png)
Works on all devices
![](https://techonespot.com/wp-content/uploads/2022/04/cloudcc0-.png)
Your own Pace
![](https://techonespot.com/wp-content/uploads/2022/04/reportcc0-.png)
Super Affordable
Popular Videos
![](https://techonespot.com/wp-content/uploads/2022/04/transparent.png)
UX for Teams
Learn the basics and a bit beyond to improve your backend dev skills.
![ava4.png ava4.png](https://techonespot.com/wp-content/uploads/elementor/thumbs/ava4-pne1fwupd8u6oz0hbx9cpklyy3iiulrtfaac6f1zsk.png)
Chris Matthews
Designer
![](https://techonespot.com/wp-content/uploads/2022/04/transparent.png)
SEO & Instagram
Learn the basics and a bit beyond to improve your backend dev skills.
![ava4.png ava4.png](https://techonespot.com/wp-content/uploads/elementor/thumbs/ava4-pne1fwupd8u6oz0hbx9cpklyy3iiulrtfaac6f1zsk.png)
Chris Matthews
Designer