Jump to content
Sign in to follow this  
residentof254

HTML JavaScript - Buttons

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

Share this post


Link to post
Share on other sites

The attribute should be onclick, not on-click.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...