iOS bind javascript function to clicking on <html>

后端 未结 2 472
心在旅途
心在旅途 2021-01-28 16:15

This works in desktop safari, but in the iOS version no alert pops up. Is it possible to bind to the \'html\' element in iOS? I want to close a drop-down menu whenever the user

2条回答
  •  孤独总比滥情好
    2021-01-28 16:25

    Use document or body element instead of html

        $(document).bind("click", function(){
              alert("clicked!")
        });
    

    You can also try this.

        $('html, body').bind("click", function(){
              alert("clicked!")
        });
    

提交回复
热议问题