简体   繁体   中英

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

In JavaScript I have this test 'ontouchstart' in document.documentElement . If the event exists (even if null) it evaluates to true otherwise to false . I don't know how to do the equivalent in CoffeeScript. Writing it exactly as is translates to using an __indexOf function which does not do the same thing (it is always returning false).

You can also try 'onmousemove' for an event that always exists.

Use of instead :

'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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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