I am trying to set the visibility of an img tag with the id of #myComputer to false if the inner html doesn't have an image source assigned.
HTML
<img id="myComputer" src="assets/myComputer.png">
JS
var myComputer = document.getElementById('myComputer').src;
var myComputerVisible = true;
if(myComputer == ""){
myComputerVisible = false;
};
When I remove the source and check the console 'myComputerVisible' still shows as "true" even if I remove the source in the html:
<img id="myComputer" src="">
Plain Javascript only. Please advise! Thank you!
Aucun commentaire:
Enregistrer un commentaire