我在处理鼠标悬停和点击事件时遇到问题。它适用于台式机/笔记本电脑网络浏览器,但不适用于 iPhone 的 Safari。这是代码:
<script type="text/javascript">
function tog(v){return v?'addClass':'removeClass';}
$(document).on('input', '.clearable', function(){
$(this)[tog(this.value)]('x');
}).on('mousemove', '.x', function( e ){
$(this)[tog(this.offsetWidth-100 < e.clientX-this.getBoundingClientRect().left)]('onX');
}).on('click', '.onX', function(){
$(this).removeClass('x onX').val('');
});
</script>
X 是出现在每个搜索字段中的清晰图标,但我无法在 iPhone 上“单击”它。将“mousemove”替换为 touchmove 无效。不幸的是,我无法改编任何 jQuery Mobile 插件,我是一个菜鸟编码。谢谢你!快乐你好'
最佳答案
对于 iPhone,您必须使用 touchstart
和 touchmove
关于javascript - iPhone 的点击和鼠标移动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19736454/