日期:2014-05-18 浏览次数:20474 次
<script type="text/javascript"> $(document).ready(function () { $("#ckbox").click(function () { if ($("#ckbox").attr("checked")) { $("#txt").attr("readonly", "readonly"); } else { $("#txt").removeAttr("readonly"); } }); }); </script>
------解决方案--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="_20120301_Default5" %> <!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 runat="server"> <title>无标题页</title> <script src="../jquery-1.3.2-vsdoc.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("#Checkbox1").click(function(){ if($(this).attr("checked") == true) { $("#Text1").attr("readonly","readonly"); } else { $("#Text1").attr("readonly",""); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <input id="Checkbox1" type="checkbox" /> <input id="Text1" type="text" /> </div> </form> </body> </html>
------解决方案--------------------
这个,2楼给的反了
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="_20120301_Default5" %> <!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 runat="server"> <title>无标题页</title> <script src="../jquery-1.3.2-vsdoc.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ $("#Checkbox1").click(function(){ if($(this).attr("checked") == true) { $("#Text1").attr("readonly",""); } else { $("#Text1").attr("readonly","readonly"); } }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <input id="Checkbox1" type="checkbox" /> <input id="Text1" type="text" readonly="readonly"/> </div> </form> </body> </html>
------解决方案--------------------
不用JQuery,用JS的方法
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs&q