如何启用文本区域或输入类型=";“文本”;使用jquery

如何启用文本区域或输入类型=";“文本”;使用jquery,jquery,html,Jquery,Html,当单击单选按钮yes时,我的代码如下:必须启用文本框,否则必须禁用。请有人帮帮我。谢谢 <div class="label_left"> <label>Does the tourism office operate on a biennial budget? : (Y/N)</label> </div> <div class="text_right"> <br> <br> <

当单击单选按钮yes时,我的代码如下:必须启用文本框,否则必须禁用。请有人帮帮我。谢谢

<div class="label_left">
    <label>Does the tourism office operate on a biennial budget? : (Y/N)</label>
</div>
<div class="text_right">
    <br>
    <br>
    <input type="radio" id="high" name="high" />
    <label>Y</label>&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="radio" id="high" name="high" />
    <label>N</label>
    <br />
    <br />
    <br />
</div>
<div class="label_left">
    <label>If YES,please indicate when the current biennial budget began: (mm/dd/yy)</label>
</div>
<div class="text_right">
    <br>
    <br>
    <input type="text" name="date_biennial_budget" id="date_biennial_budget" value="" size="30" />
    <br />
    <br />
    <br />
</div>

旅游办公室是否按两年期预算运作(是/否)


Y N


如果是,请说明当前两年期预算的开始时间:(年月日)





使用jQuery>1.6很容易

$('input').prop('disabled',true)
$('input').prop('disabled',false)
要对单选按钮做出反应,您必须为每个按钮赋予不同的值属性(1表示“是”),并收听
change
事件

$("#date_biennial_budget").change(function(){

    if($(this).val() == 1) 
       $('input[name=high]').prop('disabled',false);
    else 
       $('input[name=high]').prop('disabled',true);
}

使用jQuery>1.6很容易

$('input').prop('disabled',true)
$('input').prop('disabled',false)
要对单选按钮做出反应,您必须为每个按钮赋予不同的值属性(1表示“是”),并收听
change
事件

$("#date_biennial_budget").change(function(){

    if($(this).val() == 1) 
       $('input[name=high]').prop('disabled',false);
    else 
       $('input[name=high]').prop('disabled',true);
}
将此用于文本框

$('input[type=text]').prop('disabled',true);
更新: 因为您已经使用了
标签
标记,所以您使用
作为
属性,如下所示

<input type="radio" id="highY" name="high" />
<label for="highY">Y</label>
<input type="radio" id="highN" name="high" />
<label for="highN">N</label>

将此用于文本框

$('input[type=text]').prop('disabled',true);
更新: 因为您已经使用了
标签
标记,所以您使用
作为
属性,如下所示

<input type="radio" id="highY" name="high" />
<label for="highY">Y</label>
<input type="radio" id="highN" name="high" />
<label for="highN">N</label>

首先确保您的id是唯一的。

使用
prop()
启用/禁用元素。。(确保为代码中缺少的单选按钮添加值。

HTML

<input type="radio" id="high" value="Y" name="high"  />
<input type="radio" id="high" value="N" name="high"  />

首先确保您的id是唯一的。

使用
prop()
启用/禁用元素。。(确保为代码中缺少的单选按钮添加值。

HTML

<input type="radio" id="high" value="Y" name="high"  />
<input type="radio" id="high" value="N" name="high"  />
试试这个


尝试此操作

此操作将禁用整个
输入
标签,包括单选按钮等。此操作将禁用整个
输入
标签,包括单选按钮等。检查答案可能重复,张贴的代码非常短且简单。。。!!可能重复的检查y答案张贴非常简短和简单的代码。。。!!