Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
So I wrote this code but the image doesn't show up but when I open it with chrome and copy the link and then put the link in the code t shows up perfectly but I need to add 1 more I don't know how so pls help

What I have tried:

very thing jpg png links i don't know what else to try I got help from youtube google still not working

here is the code
<body>
<head>
<style>
button { padding:10px; margin:60px; background-color:orange; }
</style>
</head>
<script>
function light(value)
	{
	var pic;
		if(value == 0) 
		{
			img="light-bulb-off.png";
		}
		else
		{
			img="light-bulb-on.png";
		}
		document.getElementById('bulb').src=img;
	}
</script>


<img id="bulb" src="light-bulb-off.png">

<br>
<button onclick="light(1)">Turn ON</button>
<button onclick="light(0)">Turn OF</button>
</body>
Posted
Updated 1-Oct-21 4:54am
v2
Comments
Richard MacCutchan 1-Oct-21 6:19am    
Since you have not shown any code we cannot possibly suggest how to fix it.
Taha Sheikh 2021 1-Oct-21 10:53am    
ill add it now
Richard Deeming 4-Oct-21 4:56am    
After fixing your variable name, your code works fine for me: Demo[^]

You need to use your browser's developer tools to debug your code to see why it's not working for you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900