Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery在单击按钮时启用文本框_Jquery - Fatal编程技术网

使用jquery在单击按钮时启用文本框

使用jquery在单击按钮时启用文本框,jquery,Jquery,如何在链接按钮上启用文本框单击,我将在html中禁用文本框 以下是我尝试使用的jquery代码: <script type="text/javascript" language="javascript"> $(document).ready(function () { $('#lEdit').click(function () { $('#CorporationName').removeAttr('disabled');

如何在链接按钮上启用文本框单击,我将在html中禁用文本框

以下是我尝试使用的jquery代码:

<script type="text/javascript" language="javascript">
        $(document).ready(function () {
        $('#lEdit').click(function () {
            $('#CorporationName').removeAttr('disabled');
        });
    });
</script>

<asp:LinkButton ID="lEdit" runat="server" ClientIDMode="Static" >Edit</asp:LinkButton>
<asp:Label ID="lblCorporationName" runat="server" Text="Corporation Name" Width="130px"></asp:Label>
<asp:TextBox ID="CorporationName" runat="server" Width="250px" ClientIDMode="Static" Enabled="false"></asp:TextBox>

$(文档).ready(函数(){
$('#lEdit')。单击(函数(){
$(“#CorporationName”).removeAttr('disabled');
});
});
编辑

看起来你做得不错。如果这不起作用,请尝试:

$('#CorporationName').prop('disabled', false);

虽然将属性设置为false甚至null可能有效,但您可能需要尝试。它就是这样设计的

描述:删除匹配元素集的属性



请注意,以这种方式删除属性后,您将无法再次禁用文本框。

实际上,建议您不要将其用于此目的。发件人:注意:不要使用此方法删除本机属性,如已选中、已禁用或已选择。这将完全删除该属性,一旦删除,就不能再次添加到元素中。使用.prop()将这些属性改为false。
$('#CorporationName').removeProp('disabled');