首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求高人指导,jquery控制控件的禁用和启用状态解决方案

2012-05-28 
求高人指导,jquery控制控件的禁用和启用状态scripttype text/javascript functionupdae(onde){$( #b

求高人指导,jquery控制控件的禁用和启用状态
<script   type= "text/javascript ">
function   updae(onde)   {
    $( "#btnSubmit ").attr( "disabled ",   "false ");
}
</script>

<input     id= "e_name "   onblur= "return   updae(this); "     runat= "server "   onkeyup= "return   updae(this); "/>

<asp:Button   ID= "btnSubmit "   runat= "server "   Text= " "   CssClass= "btnSubmit "   Enabled= "false "   onclick= "btnSubmit_Click "   />


我想在光标离开文本框和键盘事件里把Button设为启用,jq应该怎么写呢?




[解决办法]

HTML code
<!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>
[解决办法]
HTML code
<!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> 

热点排行