iOS自动悬停修复? [英] iOS automatic hover fix?

查看:265
本文介绍了iOS自动悬停修复?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一个jQuery插件或JavaScript脚本自动循环通过每个CSS悬停(在外部样式表中找到),并绑定它与双触摸事件?

Is there a jQuery plugin or JavaScript script that automagically loops through each CSS hover (found in an external stylesheet) and binds it with a double touchdown event?


  • 触地得分1 - CSS:悬停被触发

  • 触地得分2 - 点击(链接或形成操作)

如果没有这样的东西,可以制作和如何(准则)?

If there isn't something like this yet, can it be made and how (guidelines)?

编辑:

要清楚,我不是在寻找一个双击。触地得分1是一个单一的标签,就像触动2是。

To be clear, I am not in search of a double tap. Touchdown 1 is a single tab just like Touchdown 2 is. There can be as less as 0 seconds between both or as much as 3 minutes, that's the user's choice.

无触摸:


  • :hover - >元素可见

  • 点击 - >以下链接或其他操作

触摸(iOS):


  • 触底1 - >元素变为可见

  • 触摸2 - >跟随链接或其他操作

推荐答案

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>iPad Experiment</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            if(navigator.platform == "iPad") {
                $("a").each(function() { // have to use an `each` here - either a jQuery `each` or a `for(...)` loop
                    var onClick; // this will be a function
                    var firstClick = function() {
                        onClick = secondClick;
                        return false;
                    };
                    var secondClick = function() {
                        onClick = firstClick;
                        return true;
                    };
                    onClick = firstClick;
                    $(this).click(function() {
                        return onClick();
                    });
                });
            }
        });
    </script>
    <style type="text/css">
        a:hover {
            color:white;
            background:#FF00FF;
        }
    </style>
<body>
    <a href="http://google.ca">Google</a>
    <a href="http://stackoverflow.com">stackoverflow.com</a>
</body>
</html>

...或查看演示在我的网站。注意,它设置只在iPad上工作它的魔法 - 检测所有版本的iOS是我的书中的另一个问题);

... or check out the demo on my web site. Note that it's set up to only work its magic on the iPad - detecting all versions of the iOS is another question in my books ;)

它的工作原理事实...

It works on the basis of the fact that...


点击iphone或ipad上的链接后,会留下模拟鼠标悬停,触发a:hover css样式。如果链接包含使您处于同一网页的JavaScript处理程序,则在您点击其他链接之前,悬停状态将不会更改。

After you click a link on the iphone or ipad, it leaves a simulated mouse hover that triggers the a:hover css styling on that link. If the link has a javascript handler that keeps you on same page, the hover state will not change until you click on another link.

引用: Safari iphone / ipad鼠标悬停在新链接之前的一个替换为javascript

这篇关于iOS自动悬停修复?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆