本文介绍了iPad上的jQuery mouseout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在桌面浏览器上运行良好的jQuery代码;

I have a jQuery code which works perfect on desktop browsers;

$("span#checkbox_err").mouseout(function () {
                        $("span#checkbox_err").fadeOut("slow");
                    });

但同样不会在iPad上触发(因此checkbox_err会显示在屏幕上,但是永远不会隐藏)

But the same does not trigger on the iPad (as a result the checkbox_err is displayed on screen, but never hides)

如何在iPad上触发mouseout事件?

How do I trigger the mouseout event on the iPad ?

另外我想要避免使用任何额外的库只是为了解决这个小问题..

Also I'll want to avoid using any additional library just to fix this small issue..

我有一个以后的问题

我在iPad上测试一个页面,并且面临一些实现鼠标操作行为的问题..

I am testing a page on iPad and am facing some issues implementing an equivalent of mouseout behavior..

所以这个问题很容易理解; 1.在我的页面上,点击(或者说触摸)有一个复选框,我想显示一个errorMsg 2.点击/触摸除errorMsg以外的任何内容,我想隐藏errorMsg

So the issue is very simple to understand; 1. On my page, there is a checkbox on click (or rather touch), I want to show an errorMsg 2. On click/touch on anything other than the errorMsg, I want to hide the errorMsg

以下是我写的代码;

$(document).bind("touchstart",function(e){
         if(e.target.id != "checkbox_err")
        $("span#checkbox_err").fadeOut("slow");
     });
}


$("input:checkbox").bind("touchstart",function(){
$("span#checkbox_err").fadeIn("fast");

});

现在的问题是当我点击/触摸复选框时,errorMsg会显示一段时间,然后它也会立即隐藏它(因为目标不是errorMsg)

Now the issue is when I click/touch on the checkbox, the errorMsg shows for a while and then it also hides it immediately (since target is not the errorMsg)

如何解决此问题?

推荐答案

你可以试试.blur()而不是.mouseout()

You could try .blur() instead of .mouseout()

这篇关于iPad上的jQuery mouseout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 15:56
查看更多