I have an HTML form with multiple text inputs. I want to clear the element that had the focus immediately prior to when the \'Clear\' button is pressed. How do I ge
var focused, inputs = document.getElementsByTagName('input'); for (var i=0, input; i
Or in jQuery: var focused; $('input:text').focus(function(){focused = this;});
var focused; $('input:text').focus(function(){focused = this;});
Then, when you want to clear the focused element, focused.value='';
focused.value='';