Currently i am trying to change an image on click to another image. I have managed to do so with the following code: (working)
<img id="inv1imgid" src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/X_mark.svg/525px-X_mark.svg.png" onclick="switchImage(this)" width="36" height="36" />
var preselected = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/X_mark.svg/525px-X_mark.svg.png";
var selected = "https://cdn.pixabay.com/photo/2016/03/31/14/37/check-mark-1292787_960_720.png";
var switchImage = function(image) {
if(image.src == preselected) {
image.src = selected;
} else {
image.src = preselected;
}
};
This work, but only when i give the img src an URL. I want to use: src = "selectedimg.png" and src = "preselectedimg.png", however when i do this it cant seem to find the image as no image is switched. Yes the images have those names in my wwwroot folder.