I want to create a link like this:
<a href="http://example.com">text</a>
and replace the behavior so that the link downloads the content with Ajax instead when clicking.
It is important for me not to replace the href attribute (so copying the link still works).
One solution would be to do:
$('link').onclick = function() { return false; };
but I would like to use the .observe method. But this doesn't work:
$('link').observe('click', function() { return false; });
(which is quite logical).
Any ideas on how I could achieve this?
Thanks.
You have to use the event object to achieve this with prototype.
$('link').observe('click', function(event) { event.stop() });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With