简体   繁体   English

如何检查documentElement中的项目,“输入”无效

[英]How to check for item in documentElement, 'in' is not working

In JavaScript I have this test 'ontouchstart' in document.documentElement . 在JavaScript 'ontouchstart' in document.documentElement有此测试'ontouchstart' in document.documentElement If the event exists (even if null) it evaluates to true otherwise to false . 如果事件存在(即使为null),则其结果为true否则为false I don't know how to do the equivalent in CoffeeScript. 我不知道如何在CoffeeScript中做同样的事情。 Writing it exactly as is translates to using an __indexOf function which does not do the same thing (it is always returning false). 完全按原样编写它会转换为使用__indexOf函数,该函数不会执行相同的操作(始终返回false)。

You can also try 'onmousemove' for an event that always exists. 您也可以为始终存在的事件尝试'onmousemove'

Use of instead : 使用of ,而不是:

'ontouchstart' of document.documentElement

From the documentation : 文档中

You can use in to test for array presence, and of to test for JavaScript object-key presence. 您可以使用in测试数组存在,并且of到测试JavaScript对象键的存在。

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

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