$('html').click()… anywhere except one element

前端 未结 4 1867
孤城傲影
孤城傲影 2021-02-05 05:52

I have a dynamically appended menu which I am removing if you click anywhere on page including the menu links itself. What I am trying to achieve is to prevent the remove if yo

4条回答
  •  长发绾君心
    2021-02-05 06:21

    Maybe it will work like this

    $('html').click(function(e) {                    
       if(!$(e.target).hasClass('solid') )
       {
           $('.menu').remove();                
       }
    }); 
    

    see: http://jsfiddle.net/fq86U/2/

提交回复
热议问题