jQuery check if target is link

后端 未结 7 1390
傲寒
傲寒 2021-02-07 23:49

I have a global function to capture clicks.

$(document).click(function(e){
  //do something
  if(clickedOnLink)
    //do something
});

I want t

7条回答
  •  野性不改
    2021-02-08 00:06

    Try this

    $(document).click(function(e){
      //do something
      if($(this).closest('a').length)
        //do something
    });
    

提交回复
热议问题