我想检查输入复选框时启用输入表单。
<div class="form-group clearfix">
<input type="checkbox" id="work" class="pull-left" />
<label for="work" class="form-info pull-left">
{!! Form::number('work', null, ['class' => 'form-control work','placeholder' => 'Nghề nghiệp'])!!}
</label>
</div>
<div class="form-group clearfix">
<input type="checkbox" id="city" class="pull-left" />
<label for="city" class="form-info pull-left">
{!! Form::number('city', null, ['class' => 'form-control city','placeholder' => 'Thành phố'])!!}
</label>
</div>
答案 0 :(得分:0)
为了检查是否选中了复选框,您可以像这样做一些事情。如果你不能让它工作,请告诉我,我可以提供更多帮助。
$("#work").on("change", function(){
var checked = $(this).is(':checked');
if(checked){
$("#idofwahteveryouwantdisabled").css("disabled", true);
}
else{
$("#idofwahteveryouwantdisabled").css("disabled", false);
}
}
答案 1 :(得分:0)
$("input[type=checkbox]").on("click",function(){
$("label[for="+$(this).attr("id")+"]").find("input[type=text]").prop( "disabled", (!$(this).is(":checked")) );
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="form-group clearfix">
<input type="checkbox" id="work" class="pull-left" />
<label for="work" class="form-info pull-left">
<input type="text" disabled />
</label>
</div>
<div class="form-group clearfix">
<input type="checkbox" id="city" class="pull-left" />
<label for="city" class="form-info pull-left">
<input type="text" disabled />
</label>
</div>
&#13;