IE6下,javascript控制input获取焦点时突出显示,异常
当我移动光标到下一个输入框,然后到最后一个:
可以看到,当输入框失去焦点,周围的border仍然存在。
代码如下:
JavaScript:
$().ready(function(){
if($.browser.msie){
var ie = $.browser.version;
if(ie=="6.0"){
$("input").each(function(){
$(this).focus(function(){
$(this).addClass("inputFocusIE");
});
$(this).blur(function(){
$(this).removeClass("inputFocusIE");
});
});
}
}
});.inputFocusIE{
border:expression( (this.type=="text" ||this.type=="password") ?"1px solid rgb(250,210,20)" :"none");
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../artDialog/jquery-1.7.1.min.js"></script>
<title>无标题文档</title>
<script type="text/javascript">
$(function(){
alert($("input[type='text']").length);
alert($(":input").length);
alert($(":text").length);
})
</script>
</head>
<body>
<input type="text" class="class1" />
<input type="text" class="class2" />
<input type="text" class="class3" />
</body>
</html>