How do I get the previously focused element in JavaScript?

前端 未结 7 1732
死守一世寂寞
死守一世寂寞 2021-01-04 03:46

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

7条回答
  •  不知归路
    2021-01-04 04:06

    When you click "clear" button, only element focused is "clear" button. You'll have to workaround it. (trigger onblur event)

提交回复
热议问题