日期:2014-05-16 浏览次数:20517 次
<!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" />
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#e_name").bind({
'click': function() { $("#btnSubmit").removeAttr("disabled"); },
'keyup': function() { $("#btnSubmit").removeAttr("disabled"); }
});
});
</script>
</head>
<body>
<input id= "e_name" type="text" /><button id="btnSubmit" disabled="disabled">BUTTON</button>
</body>
</html>
------解决方案--------------------
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
失焦时禁用,按 ctrl + q 启用
<input id="test" />
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
var obj = $('test');
obj.onblur = function(){
this.disabled = true;
}
document.onkeydown = function(e){
e = window.event || e;
if( e.ctrlKey && e.keyCode == 81 ){
obj.disabled = false;
obj.focus();
}
}
</script>
</body>
</html>