Skip to content

Instantly share code, notes, and snippets.

@robertknight
Created September 29, 2015 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertknight/db36abc476eeb32d884d to your computer and use it in GitHub Desktop.
Save robertknight/db36abc476eeb32d884d to your computer and use it in GitHub Desktop.
Click events in children of disabled buttons can propagate through the button in Chrome but not Firefox
<label for="enable-check">Enable button</label>
<input id="enable-check" type="checkbox">
<div id="parent">
<button id="child" disabled><div>Click me</div></button>
</div>
<script>
var enableCheckbox = document.querySelector('#enable-check');
enableCheckbox.addEventListener('click', function() {
document.querySelector('#child').disabled = !enableCheckbox.checked;
});
document.querySelector('#parent').addEventListener('click', function() {
console.log('parent of disabled button received a click');
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment