Problem with jQuery mouseleave firing when container has select box

后端 未结 9 2229
一整个雨季
一整个雨季 2021-02-13 23:47

I have a two containers -- one is nested inside of another. When I hover over the parent, I want the child container to appear. When I mouseout, I want the child container to f

9条回答
  •  广开言路
    2021-02-14 00:14

    This partly solves the problem. Unbind the mouseleave event when the select box gains focus and bind again when it loses focus.

    http://jsfiddle.net/9TZyh/5/

    $('#parent-container').live("mouseenter", function() {
        var $this = $(this);
        $selectOptionsContainer = $this.find('#child-container');
        $selectOptionsContainer.stop().fadeTo('slow', 1.0);
    }).live("mouseleave",focusOut);
    $("#select-grind-type").live("focus",function(){
        $('#parent-container').die("mouseleave");
    });
    $("#select-grind-type").live("focusout change",function(){
        $('#parent-container').live("mouseleave",focusOut);
    });
    function focusOut(e) {
        var $this = $(this),
            $selectOptionsContainer = $this.find('#child-container');
        $selectOptionsContainer.stop().hide();
    }
    

提交回复
热议问题