vikeyToy 2012-11-22 02:29 采纳率: 0%
浏览 1867
已采纳

在iPhone中,实现tap淡出效果

jQuery代码:

setTips: function() {
            $(".tooltip").parent().hover(function(){

            TT.current = $(this);
            TT.timer = setTimeout(function(){
            TT.current.find(".tooltip").fadeIn('fast');
                }, TT.delay);
            }, function(){
                clearTimeout(TT.timer);
                $(this).find(".tooltip").fadeOut('fast');

在浏览器可以正常运行,但是移植到iPhone上之后,显示工具提示后它不能隐藏了。
有没有什么方法能让tap隐藏实现淡出效果?

  • 写回答

1条回答

  • g989_1314125 2012-11-22 02:58
    关注

    可以给tap上的工具提示添加一个click事件来隐藏:

    $('body').on('click', function(e) {
        if ( $(e.target).hasClass('.element-that-called-tooltip') ) return; // return if the tapped element was one that called the tooltip
        $('.tooltip').fadeOut('fast');
    });
    

    补充:

    问题可能是iPhone悬停引起的,所以我建议无触屏绑定悬停,触屏绑定点击,

    用jsFiddle,http://jsfiddle.net/RAJ5Q/1/

    if ( $('html').hasClass('no-touch') ) {
        // 绑定到悬停事件
    }
    else {
        // 点击事件
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用