I am trying to take a button and make it to a reset button for one field in multiple field form.
<button id ="resetbutton" type="button">reset focused field</button>
<script type="text/javascript">
document.getElementById('resetbutton').onclick= function() {
// Get the focused element:
var $focused = $(':focus');
var field= document.getElementById($focused);
field.value= "";
};
</script>
the focused field variable doesn't work for me and it doesn't get the focused field that I need to reset, any suggestions?
maybe when I press the button I get a focus on the button but what I really want is latest focused field.