div滚动条上的jQuery模糊事件 [英] Jquery Blur event on div scrolbar

查看:71
本文介绍了div滚动条上的jQuery模糊事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带滚动条的div. 当我在滚动条上单击以将其向下拖动以查看div列表时,使用Firefox触发了模糊事件,并隐藏了我已设置为在触发模糊时隐藏的div. 使用滚动条时,如何防止模糊模糊:

I have a div with scroll bar. Using Firefox when I click on scroll bar to drag it down to see the div list the blur event is fired and hides my div which I have set to hide when blur is fired. How can I prevent the blur to fire when the scroll bar is used:

$("#mydiv").blur(function () {
    $('#mydiv').fadeOut();
    console.log("fadeout blur");
});

我使用以下方法显示此div

I display this div using:

 $('#mydiv').fadeIn();

我希望div在不活动时隐藏,而在尝试单击滚动条时不隐藏.

I want the div to hide when its not active but not hide when I try to click on the scroll bar.

推荐答案

也许这就是您要寻找的

$(document).ready(function(){
        $('#mydiv').fadeIn();   

        $("body").bind('click', function(ev) {
        var myID = ev.target.id;
        if (myID !== 'mydiv') {
            $('#mydiv').fadeOut();
        }
    });
});

这会将click事件与主体绑定,并检查触发click事件的元素的ID.如果它与DIV不匹配,则div将被关闭,否则div将始终处于打开状态.

This will bind the click event with the body and also check the id of the element which triggers the click event. If it doesn't match the DIV, the div will be closed else the div will be always open.

这篇关于div滚动条上的jQuery模糊事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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