为什么我的“ontouchstart”是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>
我的代码有什么问题?
谢谢
更新:*
当我添加此代码时,它可以被触发:
$('#a')[0].addEventListener("touchstart", touchstart, false);
那么,为什么 ontouchstart="touchstart(event);"
没有被触发?
This is my code:
<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>
What's wrong with my code?
Thanks
updated:*
when i add this code, it can be triggered:
$('#a')[0].addEventListener("touchstart", touchstart, false);
So, why is ontouchstart="touchstart(event);"
not being triggered?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将范围附加到作业中。试试这个
You need to append the scope to the assignment. Try this