Check if event target is hyperlink

前端 未结 3 906
长情又很酷
长情又很酷 2021-02-02 06:09

I have a large div inside there which are smaller divs, achor tags and other elements. Each large div in my program is bound to \"mousedown\" event and inside the onMouseDown ha

3条回答
  •  生来不讨喜
    2021-02-02 06:58

    You should get it through

    if(event.target.tagName.toLowerCase() === 'a')
    {
        event.target.href; //this is the url where the anchor tag points to.
    }
    

提交回复
热议问题