简体   繁体   English

每当我触摸时,都会使函数调用onclick

[英]Making a function call onclick whenever I touch

I use joystick.js . 我使用joystick.js My aim is for whenever I touch ( ontouchstart ) it will call onclick . 我的目标是每当我触摸( ontouchstart )时都将调用onclick

I tried this below but it didn't work. 我在下面尝试过,但是没有用。 My joystick is preventing me from touch buttons. 我的操纵杆使我无法触摸按钮。 I even replaced onclick with ontouchstart but I use jQuery. 我什至用ontouchstart取代了onclick ,但我使用jQuery。 I can't change all. 我不能改变一切。 For any idea I would be grateful. 对于任何想法,我将不胜感激。

document.getElementById("overlyas").ontouchstart = function(e){         
   var ontouchstart = onclick;
}

As a work around for ios not recognising the onclick event you can in your main css file set the cursor to pointer: 为了解决ios无法识别onclick事件的问题,您可以在主css文件中将光标设置为指针:

* {
    cursor: pointer;
}

then it will register onclick events. 然后它将注册onclick事件。 I think it only recognises onmousedown by default. 我认为默认情况下它仅识别onmousedown。

Not sure if this actually answers your question but it saved me a lot of trouble with writing hybrid apps.... 不知道这是否真的回答了您的问题,但是为编写混合应用程序节省了很多麻烦。

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

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