Jump to content

HTML JavaScript - Buttons


residentof254

Recommended Posts

<p><strong>My first Javascript</strong></p>

<button type="button" on-click="myfunction()">Click here</button>
<script> function myfunction() {document.getElementById("demo").innerHTML = "Hello its Wednesday";}</script>

<p id="demo">Hello its Tuesday</p> 

Any assistance would be much appreciated. I am learning the W3Schools tutorials and I can't seem to move forward. The results dont's show its a "Wednesday"!

<script>
			function 	light(sw) 	{var pic;
									if (sw == 0) {pic = "gifs/pic_bulboff.gif"} 
									else {pic = "gifs/pic_bulbon.gif"}
						document.getElementById('myImage').src = pic;</script>

			<img id="myImage" src="gifs/pic_bulboff.gif" width="100" height="180">

			<p>	<button type="button" onclick="light(1)">Light On</button>
				<button type="button" onclick="light(0)">Light Off</button></p>

I can't quite make the light bulb to go on. :sorry:

Edited by residentof254
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...