0
Js
Hi everyone Could anyone of you Tell me how to change img via javascript And thnx
6 Respostas
+ 1
Do you need to change old image with new one?
In js we change src, you will need to select image and then
element.src = "newSource";
Where newSource is path to image, it can be local(this don't work on sololearn), or url from internet
+ 1
First you have space in file name, change it to "_" or "-", space may make problem.
rename image file
Also why you use .value?
To set src we just do
element.src = "path";
And your function need to have access to element(variable) Lampe if not it can crash
Path like this("files/lampe.png") will not work on sololearn, for this you need to upload it to cloud and use as url
0
PanicS I wanna to change an img from the same source of image
0
PanicS
Function on ()
{
Lampe.src="files/lampe on.png".value
}
Is this code correct??
0
Helo
0
Rajesh Chaulagain heyy