Currently I am making a game, and I want to check if my html element 'document.getElementById("terminal").src' is equal to "sprites/terminal.png"….
Because I use a live server via visual studio code, the "document.getElementById("terminal").src" is actually equal to 'http://127.0.0.1:5500/sprites/terminal.png'. Is there a way to change this or at least shorten the '.src' to exclude 'http://127.0.0.1:5500', and just be 'sprites/terminal.png'.
Thanks
>Solution :
Instead of the src property, you could also check the src attribute, which the browser does not rewrite to an absolute URL so it will be exactly as in the HTML source:
if (document.getElementById("terminal").getAttribute('src') === 'sprites/terminal.png') {
// Do stuff
}