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
Create a global variable for storing the current focused element's id,
var cur_id;
call one function for onblur
of each of elements and pass id
and write the set the id to global variable from that function
function setId(id) {
cur_id = id;
}
and write a function for onclick of clear button, like this
function clear() {
document.getElementById(cur_id).value = "";
}