简体   繁体   中英

Jquery on click doesn't fire when blur is also bound

My blur event fires but not my click event. If I remove the blur event code the click event works fine.

How do I change the order these events fire?

$.fn.autoComplete = function () {

    $(document).on('click', '#' + settings.resultsDivId + ' tr', function () {
            console.log('click fired');
            $('#' + settings.resultsDivId).hide();
    });

    this.on('blur', function () {
        console.log('blur fired');
        $('#' + settings.resultsDivId).hide();
    });

    function AutoComplete(term) {
        // ajax call stuff
    }
};

Changing click to mousedown solved it. Apparently click fires after blur .

Blur event stops click event from working?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM