[英]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, andof
to test for JavaScript object-key presence.您可以使用
in
测试数组存在,并且of
到测试JavaScript对象键的存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.