Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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
Javascript 如何在jquery中更改复选框时创建文本框?_Javascript_Jquery_Html_Checkbox - Fatal编程技术网

Javascript 如何在jquery中更改复选框时创建文本框?

Javascript 如何在jquery中更改复选框时创建文本框?,javascript,jquery,html,checkbox,Javascript,Jquery,Html,Checkbox,我有三个复选框和一个标签。三个复选框是这样的 谷物 贾沃拉 巴吉拉 另外 更改复选框时使用事件不要生成它,只需在选中复选框时显示它即可 $“输入[名称=复选框]”。单击函数{ 如果$this.is:已选中{ $'.hidden'.show; } 否则{ $'.hidden'.hide; } }; .隐藏{ 显示:无; } 谷物 贾沃拉 巴吉拉 另外 隐藏输入 添加文本框: <label class="col-md-2 control-label" for="Checkboxes">

我有三个复选框和一个标签。三个复选框是这样的

谷物 贾沃拉 巴吉拉 另外
更改复选框时使用事件

不要生成它,只需在选中复选框时显示它即可

$“输入[名称=复选框]”。单击函数{ 如果$this.is:已选中{ $'.hidden'.show; } 否则{ $'.hidden'.hide; } }; .隐藏{ 显示:无; } 谷物 贾沃拉 巴吉拉 另外 隐藏输入 添加文本框:

<label class="col-md-2 control-label" for="Checkboxes">Grains</label>               
<div class="col-md-10 columns">                    
  <label class="checkbox-inline" for="Checkboxes_Apple"><input type="checkbox" name="Checkboxes" id="Checkboxes_Apple" value="Apple">Jawora</label>             
  <label class="checkbox-inline" for="Checkboxes_Orange"><input type="checkbox" name="Checkboxes" id="Checkboxes_Orange" value="Orange">Bajara</label>      
  <label class="checkbox-inline" for="Checkboxes_Bananas"><input type="checkbox" name="Checkboxes" id="Checkboxes_other" value="other">other</label>
  <label class="text-box" for="other"><input type="text" id="txtOther" /></label>
</div>
尝试:

给你

$'复选框\其他'.changefunction{ 如果$this.prop“checked”{ //检查输入是否已存在 if!$this.parent.find'custom_type'。长度!=0{ //附加输入 $this.parent.append; } }否则{ //如果未选中“其他”,请删除输入 $this.parent.find'custom_type'。删除; } }; 谷物 贾沃拉 巴吉拉 另外
如果你先尝试一下javascript,你很有可能会得到更多的帮助。如果当时没有人帮忙,我今天下午会帮忙,但今天早上我得去做些事情。同时,了解如何通过javascript操作DOM对象。
<label class="col-md-2 control-label" for="Checkboxes">Grains</label>               
<div class="col-md-10 columns">                    
  <label class="checkbox-inline" for="Checkboxes_Apple"><input type="checkbox" name="Checkboxes" id="Checkboxes_Apple" value="Apple">Jawora</label>             
  <label class="checkbox-inline" for="Checkboxes_Orange"><input type="checkbox" name="Checkboxes" id="Checkboxes_Orange" value="Orange">Bajara</label>      
  <label class="checkbox-inline" for="Checkboxes_Bananas"><input type="checkbox" name="Checkboxes" id="Checkboxes_other" value="other">other</label>
  <label class="text-box" for="other"><input type="text" id="txtOther" /></label>
</div>
<script type="text/javascript">
  $("#Checkboxes_other").click(function () {
    if ($(this).is(":checked")) {
       $("#txtOther").show();
    } else {
       $("#txtOther").hide();
    }
 });
</script>