Class 9th CBSE

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

Try Yourself

Fun & Easy to follow
Works on all devices
Your own Pace
Super Affordable

Popular Videos

Play Video

UX for Teams

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer

Play Video

SEO & Instagram

Learn the basics and a bit beyond to improve your backend dev skills.

ava4.png
Chris Matthews

Designer