Access event to call preventdefault from custom function originating from onclick attribute of tag

前端 未结 11 2647
粉色の甜心
粉色の甜心 2020-11-28 04:07

I have links like this:

click
c         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 04:26

    You can access the event from onclick like this:

    
    

    and at your javascript function, my advice is adding that first line statement as:

    function yourFunc(e) {
        e = e ? e : event;
    }
    

    then use everywhere e as event variable

提交回复
热议问题