编程论坛's Archiver

zero442 发表于 2008-6-12 16:04

CSS中边框变色

我有一个思路啊!想在一个文本框中,鼠标移动到文本框时,文本框的边框会变色。
我把我的代码放上来啊!!

首先是一个函数啊!!
function fEvent(sType,oInput){
                switch (sType){
                        case "focus" :
                                oInput.isfocus = true;
                        case "mouseover" :
                                oInput.style.borderColor = '#9ecc00';
                                break;
                        case "blur" :
                                oInput.isfocus = false;
                        case "mouseout" :
                                if(!oInput.isfocus){
                                        oInput.style.borderColor='#84a1bd';
                                }
                                break;
                }
        }
这个是定义一个框的样式啊!!

.inp {
        BORDER-RIGHT: #84a1bd 1px solid; PADDING-RIGHT: 2px; BACKGROUND-POSITION: -70px -424px; BORDER-TOP: #84a1bd 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; BORDER-LEFT: #84a1bd 1px solid; WIDTH: 157px; PADDING-TOP: 2px; BORDER-BOTTOM: #84a1bd 1px solid
}


接着就是一段调用的代码
<tr>
            <td width="54" height="33" align="right">用户名</td>
            <td><label>
              <input name="username" type="text" class="inp" onFocus="fEvent('focus',this)" onBlur="fEvent('blur',this)" onMouseOver="fEvent('mouseover',this)" onMouseOut="fEvent('mouseout',this)" maxlength="50"/>
              </label></td>
          </tr>

可是怎么在网页显示的时候没有出效果啊!
代码显示错误啊!!!!
请高手帮我指点啊!谢谢啊!!

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.