how to disable link in jquery

久未见 提交于 2019-12-11 17:34:38

问题


my page have a link

<a href="/hyperlink">Hyper link</a>

i want to open a dialog when user click on link.

i want to disable link without remove href event or attribute from him

means no changes in html

then

when user click on link then open a dialog

if jquery not load or have a error cause open a link directly.

how i can do this.


回答1:


$('#myLink').click(function(e) {
    e.preventDefault();
    //do other stuff when a click happens
});

That may work.



来源:https://stackoverflow.com/questions/3222420/how-to-disable-link-in-jquery

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!