Skip to content

Instantly share code, notes, and snippets.

@mabe-at
Last active August 29, 2015 14:05
Show Gist options
  • Save mabe-at/3e72f931481c23f5b8f8 to your computer and use it in GitHub Desktop.
Save mabe-at/3e72f931481c23f5b8f8 to your computer and use it in GitHub Desktop.
Firefox OS Building Blocks Input Reset JS
// helper for iterating NodeList of element objects
var forEach = Array.prototype.forEach;
forEach.call(
document.querySelectorAll('form p input + button[type="reset"], form p textarea + button[type="reset"]'),
function( el ) {
el.addEventListener ('mousedown', function () {
var field = document.querySelector('input:focus , textarea:focus');
field.value = field.defaultValue;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment