How to ignore click event when clicked on children

前端 未结 5 1211
北海茫月
北海茫月 2020-12-05 17:39

So I have the following scenario:

Sample text. Anchor link
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 18:31

    $("#block").click(function(event) {
        if($(event.target).attr('id') == $(this).attr('id'))
        {
            alert('test');
        }
    });
    

提交回复
热议问题