Search code examples
javascriptprototypejsmouseclick-event

How to capture click event in prototype


I want to prevent default link click behavior. I want that it should not redirect to that link but just show the link in alert box. I have tried this here.

document.on('click', 'a.AjaxLink', function(event, element) {
    alert(element.href);
    return false;
});

Solution

  • this should work

    document.on('click', 'a.AjaxLink', function(event, element) {
        event.stop();
        alert(element.href);
    });