IE7输入:焦点 [英] IE7 input:focus

查看:148
本文介绍了IE7输入:焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的CSS,在IE7中不工作。

I have the following CSS which isn't working in IE7.

input:focus{border-width: 2px;border-color: Blue; border-style: solid;}

基本上,我只想设置边界属性聚焦。在Firefox等工作...如果任何人可以解释为什么它不工作在IE 7和建议一个可能的解决方法,这将不胜感激。感谢。

Basically, I just want to set the border attributes when the input is focused. Works in Firefox etc... If anyone could explain why it isn't working in IE 7 and suggest a possible workaround it would be appreciated. Thanks.

推荐答案

此问题的已知答案是使用以下代码:

A known answer for this problem is using the following code:

    sfFocus = function() {
    var sfEls = document.getElementsByTagName("INPUT");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onfocus=function() {
            this.className+=" sffocus";
        }
        sfEls[i].onblur=function() {
            this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
        }
    }}
if (window.attachEvent) window.attachEvent("onload", sfFocus);

这里是css风格

input:focus, input.sffocus{background-color:#DEEFFF;}


$ b b

问题是IE根本无法识别这个样式。

The problem is that IE doesn't recognise that style at all.

编辑:你可以在这里找到一个使用原型的解决方案: http://codesnippets.joyent.com/posts/show/1837

You can find a solution using prototype here: http://codesnippets.joyent.com/posts/show/1837

这篇关于IE7输入:焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆