tags:

views:

48

answers:

1

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.

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

That may work.

Braveyard
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?
Marko
`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?"
Dan F