0

How to change source attribute for an image

3rd Jun 2021, 8:03 PM
Joshua Frimpong
Joshua Frimpong - avatar
1 Odpowiedź
+ 1
with javascript you must select the targeted image(s) from dom using getElement(s) or querySelector families methods and assign to it (or each items if many selected) its (their) 'src' property with the url of the image you want to be loaded/displayed ;P alternativaly, if you use an id on it that conform js variable names rules, and you don't declare/use the same variable name in the global scope, this name was implicitly declared and prefilled with the related element reference ;) if you declare a variable with same name in a local scope where you want to access the global one value, you must use it through the 'window' object property of that name...
3rd Jun 2021, 8:51 PM
visph
visph - avatar