Posts

Showing posts from July, 2007

About html link tag <a>'s HREF

1.adds # to the browser url and jumps to the top of the page. <a href="#">link</a> 2.simply "ignores" the link click. <a href="#" onclick="return false;">link</a> <a href="#" onclick="foo(); return false;">link</a> <a href="#" onclick="return foo();">link</a> <a href="javascript:;">link</a> <a href="javascript:void(0);">link</a> <a href="javascript:return false;">link</a> $('#myDiv a[href]').click(function (event) { event.preventDefault(); // your other click code here }); The hash is safest, just in case your user has Javascript disabled. You can solve it easily using jQuery to all the links with this value in your document : $('a[href="#"]').click(function(e) { e.preventDefault ? e.preventDefault() : e.returnValue = false; });