我有这样的复选框
<div class="icheck" style="margin-top: 5px !important;">
<input type="checkbox"
name="param_{{ $item->id }}"
d="param_{{ $item->id }}"
value="1"
class="checkListItem"
@if ($item->value == 1) checked @endif>
</div>
选中时,它将值设置为1,否则为0
$('body')
.on('ifChecked', '.checkListItem', function(){
$(this).val(1);
})
.on('ifUnchecked', '.checkListItem', function(){
$(this).val(0);
);
如果计算机不是触摸屏,它在手机和计算机上运行良好。在触摸屏电脑(Linux除外)上,它不会检查复选框。
我尝试点击点击事件,但它无法正常工作
$('.checkListItem').on('click tap', function(e){
console.log("works");
e.preventDefault();
});
我有点失落。更是如此,因为它适用于带有linux的触摸屏电脑。可能是什么问题呢?如何在触摸屏计算机上输入type =“checkbox”?
谢谢!
$('.radiogroup').on('click touchend',function(){
console.log("works");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="radio" name="radiog" id="male" class="radiogroup" checked> Male
<input type="radio" name="radiog" id="femail" class="radiogroup"> Female
试试Touchstart
或touchend
用于触摸设备
$('.checkListItem').on('click touchstart touchend', function(e){
console.log("works");
e.preventDefault();
});