jQtouch点击和链接问题
我在使用点击链接时遇到了 jQtouch 问题,
我试图在点击 iphone 应用商店(蓝色)时获取一个更改背景颜色的链接,
所以我使用以下代码:
<script>
var jQT = new $.jQTouch({
statusBar: 'black',
useFastTouch: true
});
$(function(){
$("a").live('tap', function() {
$(this).addClass("active");
},function() {
$(this).removeClass("active");
});
});
</script>
“.active”样式包含蓝色背景:
.active {
background-image: -webkit-gradient(linear, left top, left bottom, from(#048bf4), to(#015de6));
}
链接是这样的:
<a id="a" href="http://google.com"><img src="someimage.png"><div>Google</div></a>
问题是,当我点击链接时,背景会按预期更改,但链接不起作用,并且当我移开手指时新背景不会被删除^^
有人可以吗指出我做错了什么:/?
I'm having a problem with jQtouch when using tap on links,
I'm trying to get a link to change background color when tapped a la iphone appstore (the blue color)
so I'm using this code :
<script>
var jQT = new $.jQTouch({
statusBar: 'black',
useFastTouch: true
});
$(function(){
$("a").live('tap', function() {
$(this).addClass("active");
},function() {
$(this).removeClass("active");
});
});
</script>
the ".active" style contains the blue background :
.active {
background-image: -webkit-gradient(linear, left top, left bottom, from(#048bf4), to(#015de6));
}
and links are like this :
<a id="a" href="http://google.com"><img src="someimage.png"><div>Google</div></a>
The problem is, when I tap the link, the background changes as expected but the link doesn't work and the new background is not removed when I remove the finger ^^
Could someone point out what I'm doing wrong :/ ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果单击或点击锚点,“活动”类应该自动添加到锚点,因此您不需要自己添加和删除“活动”类。
您应该将正常的背景图像分配给锚元素,并将活动背景图像分配给 a:active:
希望这能解决您的问题。
The "active" class should be automatically added to an anchor if it is clicked or tapped, so you shouldn't need to add and remove the "active" class yourself.
You should have the normal background image assigned to anchor elements and an active background image for a:active:
Hopefully this will solve your question.
谢谢威廉,
我删除了 jQtouch 并仅使用 jQuery 添加了点击事物的代码,
我在这里放置了一个示例: http://fun.r4dius.net/temp/iphone.html
它的工作原理基本上是这样的:
这是我面临的最后一个问题:/
出于某种原因,如果我点击,那么我会在该元素完全相同的时间开始移动设置为活动状态(100毫秒延迟后),它保持活动状态直到发生“touchend”,而不是按应有的方式删除活动类,有人明白为什么吗?
我在jQtouch预览页面上测试了这个,但无法重现它,
但如果我在我的页面上使用 jQtouch ,问题也会发生:/
Thanks William,
I removed jQtouch and added code for the tap thing with jQuery only,
I've put a sample here : http://fun.r4dius.net/temp/iphone.html
it works basically like this:
Here's the last problem I'm facing :/
For some reason, if I tap, then I start moving at the exact same time that the element is set to active (after the 100ms delay), it stays active until a "touchend" occurs, rather than removing the active class as it should, does someone understand why ?
I tested this on the jQtouch preview page and could not reproduce it,
but if I use jQtouch on my page the problem occurs the same :/