移动/触摸设备捕获文本评选活动 [英] capturing text selection event on mobile/touch devices

查看:112
本文介绍了移动/触摸设备捕获文本评选活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的HTML应用程序我想每个一些文字被选定的时间做一个动作。
现在,我用鼠标松开事件捕捉文本选择像显示在下面的code。但在移动设备上,这并不工作,因为鼠标松开是不是一个选择之后解雇。我可以使用哪些事件呢?

  $(#容器周围的文本)。在('mouseup事件',函数(){
  //检查,如果选择为空
  //然后做一些事情
});


解决方案

您也许可以存储变量selectedText并运行间隔每100ms左右的检查,看看如果当前选定的文本是一样selectedText变量店。如果是不同的,执行的操作。

For my html application I want to do an action every time that some text is selected. Right now I'm using the mouseup event to catch text selection like shown in the code below. But on mobile devices this does not work since mouseup is not fired after a selection. Which event can I use instead?

$("#container-around-text").on('mouseup', function() {
  // check if selection is empty
  // then do something
});

解决方案

You could maybe store a variable selectedText and run an interval every 100ms or so that checks to see if the current selected text is the same as that store in selectedText variable. If it is different, perform an action.

这篇关于移动/触摸设备捕获文本评选活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆