我有这样的复选框
<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的触摸屏电脑上运行。可能的问题是什么?如何在触摸屏电脑上使用input type="checkbox“?
谢谢!
发布于 2018-09-18 15:46:50
$('.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();
});
https://stackoverflow.com/questions/52381401
复制相似问题