我有一個包含引導程序開關列表的面板,旁邊有一個clockpicker。防止其他元素事件上元素的默認行爲
我想要做的是,當開關切換到OFF時,我想阻止clockpicker的默認行爲(即使用preventDefault()
),因此它不再可觸發。
我想簡單地禁用clockpicker,但它不工作:
$("#switch").change(function(){
if (this.checked == false)
{ $("#clockpicker1").prop("disabled", true") }
})
爲Clockpicker HTML結構:
<li class="list-group-item-padding">
<div class="input-group clockpicker" id="ddd" data-placement="left" data-align="top" data-autoclose="true">
<input type="text" id="saturdayPicker1" class="form-control" value="15:00" />
<span class="input-group-addon" id="saturdayPickerSpan1">
<span id="saturdayIcon1" class="glyphicon glyphicon-time">
</span>
</span>
</div>
</li>
HTML結構開關:
<li class="list-group-item">Sunday
<div class="material-switch pull-right">
<input id="sundaySwitch" name="daySwitch" type="checkbox" />
<label for="sundaySwitch" class="label-primary"></label>
</div>
</li>
可以添加HTML結構,以及... –
@ MayankRaj我已經在您的解決方案中添加了所需的html結構 –