1. <i id='MsHMH'><tr id='MsHMH'><dt id='MsHMH'><q id='MsHMH'><span id='MsHMH'><b id='MsHMH'><form id='MsHMH'><ins id='MsHMH'></ins><ul id='MsHMH'></ul><sub id='MsHMH'></sub></form><legend id='MsHMH'></legend><bdo id='MsHMH'><pre id='MsHMH'><center id='MsHMH'></center></pre></bdo></b><th id='MsHMH'></th></span></q></dt></tr></i><div id='MsHMH'><tfoot id='MsHMH'></tfoot><dl id='MsHMH'><fieldset id='MsHMH'></fieldset></dl></div>
      • <bdo id='MsHMH'></bdo><ul id='MsHMH'></ul>
    2. <tfoot id='MsHMH'></tfoot><legend id='MsHMH'><style id='MsHMH'><dir id='MsHMH'><q id='MsHMH'></q></dir></style></legend>

        <small id='MsHMH'></small><noframes id='MsHMH'>

        在 jQueryMobile 中触摸后悬停效果保持不变

        Hover effect stays after touch in jQueryMobile(在 jQueryMobile 中触摸后悬停效果保持不变)
        <legend id='Zug5F'><style id='Zug5F'><dir id='Zug5F'><q id='Zug5F'></q></dir></style></legend>

                <bdo id='Zug5F'></bdo><ul id='Zug5F'></ul>

                  <tbody id='Zug5F'></tbody>
                <tfoot id='Zug5F'></tfoot>
                <i id='Zug5F'><tr id='Zug5F'><dt id='Zug5F'><q id='Zug5F'><span id='Zug5F'><b id='Zug5F'><form id='Zug5F'><ins id='Zug5F'></ins><ul id='Zug5F'></ul><sub id='Zug5F'></sub></form><legend id='Zug5F'></legend><bdo id='Zug5F'><pre id='Zug5F'><center id='Zug5F'></center></pre></bdo></b><th id='Zug5F'></th></span></q></dt></tr></i><div id='Zug5F'><tfoot id='Zug5F'></tfoot><dl id='Zug5F'><fieldset id='Zug5F'></fieldset></dl></div>

                  <small id='Zug5F'></small><noframes id='Zug5F'>

                  本文介绍了在 jQueryMobile 中触摸后悬停效果保持不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 jQueryMobile 在 phonegap 中开发应用程序,仅适用于移动设备.我在其中搜索图标.当用户触摸它时,我想在该图标上赋予悬停效果.

                  I'm developiong application in phonegap with jQueryMobile for mobile devices only. In which I've search icon. I want to give hover effect on that icon when user touchs it.

                  我已经通过 css 实现了这一点:

                  I've achived this by css:

                  <a href="search.html" class="custom_header" >
                  
                      .custom_header:hover {
                          background:url('../images/effect_glow.png') no-repeat center;
                  

                  现在的问题是这种悬停效果在触摸后仍然存在.我想要mousein和mouseout这样的行为.在这种情况下,即使那部分没有接触,效果也会保持不变.

                  Now the problem is this hover effect stays after touch. I want behaviour like mousein and mouseout. In this case effect stays even that part is not touching.

                  手指离开后如何消除悬停效果?

                  How to remove hover effect after finger get off on it?

                  推荐答案

                  您可能知道这一点,但 :hover 在触摸屏设备上不存在.因此,当您设计一个响应式网站时,您应该仔细计划何时何地使用 :hover 交互.

                  You maybe know this but :hover doesn’t exist on touch screen devices. So when you design a responsive website, you should carefully plan when and where to use :hover interactions.

                  虽然它是在移动设备上实现的,但它的漏洞非常多,主要是在 iOS 设备上.另一方面,您不能使用 :focus,因为它只能用于支持焦点的元素,因此排除了标签和按钮.:active 也不适用于移动设备.

                  While it is implemented on mobile devices it is extremely buggy, mostly on iOS devices. On the other end you cant use :focus because it can be used only on a elements that support focus so a tags and buttons are ruled out. Also :active is no go on mobile devices.

                  在这种情况下,我们可以使用 jQuery 来解决这个问题.

                  In this case we can use jQuery to remedy this problem.

                  工作示例:http://jsfiddle.net/Gajotres/84Nug/

                  在这个例子中,我使用了 vmousedownvmouseupvmousecancel 事件,所以我可以在桌面/移动设备上测试它.只需将它们替换为 touchstarttouchendtouchcancel>.

                  In this example I have used vmousedown, vmouseup and vmousecancel events so I can test it on desktop / mobile devices alike. Just replace them with touchstart, touchend and touchcancel.

                  touchcancel/vmousecancel 是必需的,因为有时按钮可以保持按下状态.

                  touchcancel / vmousecancel is needed because sometimes button can stay in pressed state.

                  代码:

                  $(document).on('pagebeforeshow', '#index', function(){ 
                      $(document).on('touchstart','.custom_header' ,function(){
                          $(".custom_header").css("background","url('http://www.cesarsway.com/sites/default/files/cesarsway-images/features/2012/March/Puppies-and-Exercise.jpg') no-repeat center");
                      }).on('touchend', function(){
                          $(".custom_header").css("background","red");
                      }).on("touchcancel", function() {
                          $(".custom_header").css("background","red");
                       }); 
                  });
                  

                  这篇关于在 jQueryMobile 中触摸后悬停效果保持不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Move link image 5px up on hover(悬停时将链接图像向上移动 5px)
                  How do I inspect CSS pseudo classes with firebug?(如何使用 firebug 检查 CSS 伪类?)
                  Why doesn#39;t CSS hover work on table rows when the cells inside the rows have class names?(当行内的单元格具有类名时,为什么 CSS 悬停在表格行上不起作用?)
                  Hover image - display div over it(悬停图像 - 在其上显示 div)
                  How to apply a CSS class on hover to dynamically generated submit buttons?(如何在悬停时将 CSS 类应用于动态生成的提交按钮?)
                  Differences between CSS3 :hover and :focus?(CSS3 :hover 和 :focus 的区别?)

                    <bdo id='2YrS4'></bdo><ul id='2YrS4'></ul>
                    <i id='2YrS4'><tr id='2YrS4'><dt id='2YrS4'><q id='2YrS4'><span id='2YrS4'><b id='2YrS4'><form id='2YrS4'><ins id='2YrS4'></ins><ul id='2YrS4'></ul><sub id='2YrS4'></sub></form><legend id='2YrS4'></legend><bdo id='2YrS4'><pre id='2YrS4'><center id='2YrS4'></center></pre></bdo></b><th id='2YrS4'></th></span></q></dt></tr></i><div id='2YrS4'><tfoot id='2YrS4'></tfoot><dl id='2YrS4'><fieldset id='2YrS4'></fieldset></dl></div>
                      <tbody id='2YrS4'></tbody>

                    <small id='2YrS4'></small><noframes id='2YrS4'>

                      <tfoot id='2YrS4'></tfoot>
                      1. <legend id='2YrS4'><style id='2YrS4'><dir id='2YrS4'><q id='2YrS4'></q></dir></style></legend>