0

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 Answer 1

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

That may work.

Sign up to request clarification or add additional context in comments.

2 Comments

Which is better, preventDefault or return false? Both do the same job (as far as I'm concerned) but preventDefault seems to have a more meaningful name. Any ideas?
preventDefault for sure for me. Return false might do the trick, but preventDefault has more semantic meaning, it leaves a better breadcrumb trail for the next coder to come along and wonder "why are they returning false when the function worked?"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.