这里我有两个字段
假设我正在点击属性类型 Plot / Site / Land 我想取消选中卧室,怎么办呢?
Property Type :
<fieldset class="checkboxes">
<label><input type="checkbox" name="propertyType" value="4" onclick="myFunction()"> Apartment</label>
<label><input type="checkbox" name="propertyType" value="5" onclick="myFunction()"> Independent House/ Villa</label>
<label><input type="checkbox" name="propertyType" value="6" onclick="myFunction()"> Individual House/ Standalone Building</label>
<label><input type="checkbox" name="propertyType" value="7" onclick="myFunction()"> Plot/Site/Land</label>
</fieldset>
Bedroom:
<ul style="padding-left: 0px;">
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 Room/Hall" name="unitType" type="checkbox" onclick="myFunction()">1 Room/Hall</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 RK" name="unitType" type="checkbox" onclick="myFunction()">1 RK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 BHK" name="unitType" type="checkbox" onclick="myFunction()">1 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="2 BHK" name="unitType" type="checkbox" onclick="myFunction()">2 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="3 BHK" name="unitType" type="checkbox" onclick="myFunction()">3 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="4 BHK" name="unitType" type="checkbox" onclick="myFunction()">4 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="4+ BHK" name="unitType" type="checkbox" onclick="myFunction()">4+ BHK</label></li>
</ul>
&#13;
答案 0 :(得分:3)
在您的媒体资源类型框中注册change()
收听者,并取消选中所有单位类型。
$(function() {
$("input[name=propertyType]").change(function() {
$("input[name=unitType]").prop("checked", false);
});
});
function myFunction() {
console.log('myfunction called');
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Property Type :
<fieldset class="checkboxes">
<label><input type="checkbox" name="propertyType" value="4" onclick="myFunction()"> Apartment</label>
<label><input type="checkbox" name="propertyType" value="5" onclick="myFunction()"> Independent House/ Villa</label>
<label><input type="checkbox" name="propertyType" value="6" onclick="myFunction()"> Individual House/ Standalone Building</label>
<label><input type="checkbox" name="propertyType" value="7" onclick="myFunction()"> Plot/Site/Land</label>
</fieldset>
Bedroom:
<ul style="padding-left: 0px;">
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 Room/Hall" name="unitType" type="checkbox" onclick="myFunction()">1 Room/Hall</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 RK" name="unitType" type="checkbox" onclick="myFunction()">1 RK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="1 BHK" name="unitType" type="checkbox" onclick="myFunction()">1 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="2 BHK" name="unitType" type="checkbox" onclick="myFunction()">2 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="3 BHK" name="unitType" type="checkbox" onclick="myFunction()">3 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="4 BHK" name="unitType" type="checkbox" onclick="myFunction()">4 BHK</label></li>
<li class="col-md-12" style="padding-left: 0px;"><label class="space"><input value="4+ BHK" name="unitType" type="checkbox" onclick="myFunction()">4+ BHK</label></li>
</ul>
&#13;