Change an element's onfocus handler with Javascript?
问题 I have a form that has default values describing what should go into the field (replacing a label). When the user focuses a field this function is called: function clear_input(element) { element.value = ""; element.onfocus = null; } The onfocus is set to null so that if the user puts something in the field and decides to change it, their input is not erased (so it is only erased once). Now, if the user moves on to the next field without entering any data, then the default value is restored