Home > Enterprise >  Disabling a type="image" input won't work on Firefox
Disabling a type="image" input won't work on Firefox

Time:09-06

I am trying to disable a button I made for a game. When I open the game in all the other browsers, the button is disabled. But, when I open the game in Firefox, the button is not disabled. If I switch the input type to "button", the button disables. Here is the code:

<input type="image" src="mapIcon.png" alt="mapIcon" id="mapIcon" onclick="openMap()" disabled>

CodePudding user response:

This question is a dupe, but found the answer within 5 seconds of searching.

https://stackoverflow.com/a/3447442/19447792

document.getElementbyId(ID).setAttribute('disabled', true|false); Works on IE/FF/GC

So:

<input type="image" src="mapIcon.png" alt="mapIcon"  id="mapIcon" onclick="openMap()">

<script>
#disable
document.getElementbyId('mapIcon').setAttribute('disabled', true);

#enable
document.getElementbyId('mapIcon').setAttribute('disabled', false);
</script>
  •  Tags:  
  • html
  • Related