简体   繁体   English

如何在Javascript中侦听Tapped事件

[英]How to listen for Tapped event in Javascript

I have the following sample function code to be called when the user Tap on a word and then tapped event should occur to Unhighlight that selected text.But in Javascript there is no such event. 当用户点击一个单词然后轻击事件以取消突出显示所选文本时,将调用以下示例函数代码,但是在Javascript中没有此类事件。

 deleteHighlight:function(){
    var element = contentDoc.getElementsByClassName('highlighted');
    element.style.backgroundColor = "white";  
}

How to listen for that event and handle the same when the user tap on that word.? 当用户点击该单词时,如何监听该事件并进行处理?

any help is highly appreciated. 非常感谢您的帮助。

Note :No jquery please.I want this to be done only in javascript 注意 :请不要使用jQuery。我希望仅在javascript中完成此操作

您可以使用touchstart当字被窃听和touchend以恢复至原始状态

http://www.w3.org/TR/touch-events/#idl-def-TouchEvent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM