Hyperlink jQtouch抽头和链接问题

Hyperlink jQtouch抽头和链接问题,hyperlink,jqtouch,tap,Hyperlink,Jqtouch,Tap,我在使用点击链接时遇到jQtouch问题 我试图获得一个链接,以改变背景颜色时,点击了洛杉矶iphone应用商店的蓝色 因此,我使用以下代码: <script> var jQT = new $.jQTouch({ statusBar: 'black', useFastTouch: true }); $(function(){ $("a").live('tap', function() {

我在使用点击链接时遇到jQtouch问题

我试图获得一个链接,以改变背景颜色时,点击了洛杉矶iphone应用商店的蓝色

因此,我使用以下代码:

<script>
    var jQT = new $.jQTouch({
        statusBar: 'black',
        useFastTouch: true
    });
    $(function(){
        $("a").live('tap', function() {
            $(this).addClass("active");
        },function() {
            $(this).removeClass("active");
        });
    });
</script>
链接如下:

<a id="a" href="http://google.com"><img src="someimage.png"><div>Google</div></a>
问题是,当我点击链接时,背景会像预期的那样发生变化,但链接不起作用,并且当我移除手指时,新的背景不会被移除^^


有人能指出我做错了什么吗:/?

如果单击或点击活动类,它应该自动添加到锚点,因此您不需要自己添加和删除活动类

应将普通背景图像指定给定位元素,并为:active:

a {
  background-image: ...
}

a:active {
  background-image: ...
}
希望这能解决你的问题。

谢谢威廉, 我删除了jQtouch,并仅使用jQuery为tap添加了代码

$(document).ready(function() {
    var delay = 100;
    var hovertime = null;
    var hoverdelay = null;
    $("#list a").bind('touchstart mouseover', function(){
        clearTimeout(hoverdelay);
        hovertime = new Date().getTime();
        var $el = $(this).add("*", this);
        hoverdelay = setTimeout(function(){
            $el.addClass("active");
        }, delay);
    });
    $("#list a").bind('touchend mouseup', function() {
        clearTimeout(hoverdelay);
        var now = new Date().getTime();
        var $el = $(this).add("*", this);
        if(now < hovertime + delay) {
            $el.addClass("active");
            setTimeout(function(){
                $el.removeClass("active");
            }, delay);
        } else {
            $el.removeClass("active");
        }
    });
    $("#list a").bind('touchmove touchcancel mouseout', function() {
        clearTimeout(hoverdelay);
        var $el = $(this).add("*", this);
        $el.removeClass("active");
    });
});
我在这里放了一个样本:

它基本上是这样工作的:

当点击时,它只会在100毫秒超时后切换到活动状态,因此如果您只想滑动页面,它不会在每次点击时激活, 切换到“活动”时,元素的所有child*也设置为“活动” 当结束水龙头时 如果处于活动状态,则会删除活动类, 如果在设置active之前touchend出现快速点击,我们仍然会切换到active,并在100毫秒延迟后将其删除,以显示它已录制 如果我们在录制时移动,活动类将被删除 这是我面临的最后一个问题:/

出于某种原因,如果我点击,那么我会在100毫秒延迟后元素设置为活动的同一时间开始移动,它会一直保持活动状态,直到出现touchend,而不是像应该的那样删除活动类,有人知道为什么吗

我在jQtouch预览页面上测试了这个,但无法复制, 但如果我在页面上使用jQtouch,问题也会出现:/

$(document).ready(function() {
    var delay = 100;
    var hovertime = null;
    var hoverdelay = null;
    $("#list a").bind('touchstart mouseover', function(){
        clearTimeout(hoverdelay);
        hovertime = new Date().getTime();
        var $el = $(this).add("*", this);
        hoverdelay = setTimeout(function(){
            $el.addClass("active");
        }, delay);
    });
    $("#list a").bind('touchend mouseup', function() {
        clearTimeout(hoverdelay);
        var now = new Date().getTime();
        var $el = $(this).add("*", this);
        if(now < hovertime + delay) {
            $el.addClass("active");
            setTimeout(function(){
                $el.removeClass("active");
            }, delay);
        } else {
            $el.removeClass("active");
        }
    });
    $("#list a").bind('touchmove touchcancel mouseout', function() {
        clearTimeout(hoverdelay);
        var $el = $(this).add("*", this);
        $el.removeClass("active");
    });
});