Detect which form input has focus using JavaScript or jQuery

前端 未结 9 2556
灰色年华
灰色年华 2020-11-29 09:20

How do you detect which form input has focus using JavaScript or jQuery?

From within a function I want to be able to determine which form input has focus. I\'d like

9条回答
  •  孤独总比滥情好
    2020-11-29 09:47

    If all you want to do is change the CSS for a particular form field when it gets focus, you could use the CSS ":focus" selector. For compatibility with IE6 which doesn't support this, you could use the IE7 library.

提交回复
热议问题