Last active
August 29, 2015 14:05
-
-
Save mabe-at/3e72f931481c23f5b8f8 to your computer and use it in GitHub Desktop.
Firefox OS Building Blocks Input Reset JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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