[Gambas-user] JavaScript Learning
Martín
mbelmonte at belmotek.net
Mon Nov 20 14:36:56 CET 2023
Hi,
I'm not sure if this is the right place to ask about a language other
than gambas3 but I'm new to the javascript world and I don't know any
forum where to ask. I hope you don't mind.
In JS, can someone here tell me how to get the object (an image) that I
click on and according to the .src property I can change it to another
image path?
This code
|let miImage = document.querySelector("img"); miImage.onclick = function
() { let miSrc = miImage.getAttribute("src"); if (miSrc ===
"images/firefox-icon.png") { miImage.setAttribute("src",
"images/firefox2.png"); } else { miImage.setAttribute("src",
"images/firefox-icon.png"); } }; But its work if there are only 1 image
I want to click on several images and get the same behavior. I want to
act over an list item like: ||let aImage = document.querySelectorAll("img");|
||Im folowing this course
https://developer.mozilla.org/es/docs/Learn/Getting_started_with_the_web/JavaScript_basics
if someone has a little patience and time to answer some questions about
this language it would help me a lot to go faster.
Regards.
Martin.
More information about the User
mailing list