#Hahahaha It's not about your bed rooms bulb. Its a JavaScript coding tutorial or you can say JavaScript Tips & Tricks.
Let's see How you can Turn On or Off bulb by using JavaScript ?
Before go ahead one second,Let me tell you one thing, are you seriously thinking about your bad room's bulb ? No no this is not your rooms bulb its a programming bulb it can only understand by the most intelligent people in this world called PROGRAMMERs.
So Let's see
How you can Turn On or Off your Programming Bulb by using JavaScript ?
Here are some basic JavaScript Syntax that will help you to understand basic about how to Turn On or Off bulb.
Syntax :
img src = image_name.pngIn this JavaScript code you have two images of bulb that define the two states of the bulb, The first image or state is for Turn Off state and the second image or state is for Turn On state,
Turn Off State ; img src = Turn_Off_Image.png Turn On State : img src = Turn_On_Image.png
Turn OFF State
JavaScript Code :
<html> <body> <img src = "BulbTurnOffImage.jpg" alt="Turn Off" />
<h3>Click on the Bulb to Turn it ON</h3>
<script>
//This JavaScript function check the above image condition if its is bulb OFF condition than this function will Turn it On.
function TurnOnOff(){
var image= decument.getElementById("image");
if ( image.src.match("BulbOn") )
image src = "Turm OFF image.jpg"
else
image src = "Turn ON image.jpg"
} </script>
</body> </html>
<h3>Click on the Bulb to Turn it ON</h3>
<script>
//This JavaScript function check the above image condition if its is bulb OFF condition than this function will Turn it On.
function TurnOnOff(){
var image= decument.getElementById("image");
if ( image.src.match("BulbOn") )
image src = "Turm OFF image.jpg"
else
image src = "Turn ON image.jpg"
} </script>
</body> </html>
Output :
Turn ON State
Now your JavaScript Programming bulb On, You can try it by Yourself too. If you have Question don't forget to ask your question in Comment Box.
Awesome yaar thanks for this
ReplyDeleteHey it's work. Good
ReplyDeleteThis blog provide some useFul knowledge. Thanks for sharing this knowledge
ReplyDeleteUseful
ReplyDeleteI don't understand
DeleteI thing you should read this post carefully from starting to end you can copy this code and run it yourself.
DeleteIt didn't work for me.How did u guys do it?
ReplyDelete