开发者

Using Modernizr to style input:focus, input:active

How can I test 开发者_如何学编程for and style input:focus and input:active in IE7/8 (which don't support these properties) using Modernizr?

Or should I just use basic JS/CSS to do so? What would be a good way to do this?


Here's a solution outside of Modernizr, but it works very much the same way (by adding an element to the DOM, styling it's :hover state, and then testing if the state has happened).

Kudos to James Padolsey for this article.

You may have to check for other events than mousedown and mouseup for the active state, but this seems to work for modern browsers (maintaining native :focus and :active states) as well as IE7 (with the fake .focus and .active classes).

Fiddle

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜