+ 1

How to compare an image's url in javascript

I want to switch an image whenever it is clicked currently I am using this code. x stores the class I have assigned with background. if(x.style.backgroundImage=="URL('1.jpg')") x.style.backgroundImage=URL('2.jpg'); else something else

19th Mar 2017, 3:17 PM
Kartikeya Kotnala
Kartikeya Kotnala - avatar
2 odpowiedzi
0
There's a image slider tutorial in last chapter (DOM & Events) of Javascript that is quite useful. It stores image url in an array, creates a function that change the array number while onclick event is triggered. Check it out.
19th Mar 2017, 3:49 PM
Nicolas Bonnet
Nicolas Bonnet - avatar
0
thank u nicholas
19th Mar 2017, 7:32 PM
Kartikeya Kotnala
Kartikeya Kotnala - avatar