为什么我的“onuchstart”事件不会在iPhone上触发? [英] Why is my 'ontouchstart' event not being triggered on iPhone?
本文介绍了为什么我的“onuchstart”事件不会在iPhone上触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码:
<div id="a" ontouchstart="touchstart(event);" style="width:100px ; height:100px;background:red;"></div>
<script src="jquery-1.4.2.js" type="text/javascript"></script>
<script>
function touchstart(event){
$('#a').css('width','1000px')
}
</script>
我的代码有什么问题?
谢谢
更新:*
当我添加这个代码,它可以触发:
when i add this code, it can be triggered:
$('#a')[0].addEventListener("touchstart", touchstart, false);
所以,为什么 touchstart =touchstart(event); code>不被触发?
So, why is ontouchstart="touchstart(event);"
not being triggered?
推荐答案
您需要将作用域附加到作业中。尝试这个
You need to append the scope to the assignment. Try this
<div id="a" ontouchstart="javascript:touchstart(event);" style="width:100px ; height:100px;background:red;"></div>
这篇关于为什么我的“onuchstart”事件不会在iPhone上触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文