0

Js

Hi everyone Could anyone of you Tell me how to change img via javascript And thnx

2nd Jan 2023, 5:55 PM
👉 Khouloud Tlili 🤞🤌
👉 Khouloud Tlili 🤞🤌 - avatar
6 odpowiedzi
+ 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
2nd Jan 2023, 6:39 PM
PanicS
PanicS - avatar
+ 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
2nd Jan 2023, 9:09 PM
PanicS
PanicS - avatar
0
PanicS I wanna to change an img from the same source of image
2nd Jan 2023, 6:42 PM
👉 Khouloud Tlili 🤞🤌
👉 Khouloud Tlili 🤞🤌 - avatar
0
PanicS Function on () { Lampe.src="files/lampe on.png".value } Is this code correct??
2nd Jan 2023, 6:46 PM
👉 Khouloud Tlili 🤞🤌
👉 Khouloud Tlili 🤞🤌 - avatar
0
Helo
3rd Jan 2023, 1:41 PM
Rajesh Chaulagain
Rajesh Chaulagain - avatar
5th Jan 2023, 8:18 PM
👉 Khouloud Tlili 🤞🤌
👉 Khouloud Tlili 🤞🤌 - avatar