detect the click outside of input

This question already has an answer here:

  • How do I detect a click outside an element? 76 answers

  • $(document).on('click', function(e) {
        if ( e.target.id != 'ok' ) {
            // you clicked something else
        }
    });
    

    That would capture any click except on the input, but why would you need it ?

    To capture only clicks on .hor-minimalist-a and not the entire document, just replace document with that selector in the code above.


    How about:

    $('.hor-minimalist-a').on('click',':not(#ok)',function(){
    

    That'll register click events within .hor-minimalist-a but outside the input #ok


    有一个jquery插件:http://benalman.com/code/projects/jquery-outside-events/examples/clickoutside/

    链接地址: http://www.djcxy.com/p/14710.html

    上一篇: 从下拉菜单中“点击”的最佳方式?

    下一篇: 检测输入之外的点击