How to connect both onclick () and href to the <a> element but have only one job at a time
I have an element like this:
<a class='link' href='/page1'>Page 1</a>
This click handler has this:
$('.link').click(function() { loadPage('page1'); });
Clicking a link loads a new page. However, there are two options for loading a new page. One of them is through AJAX, which determines which elements have been changed between pages and reloads sections without updating based on this, and one of them loaded using a regular GET request.
I would like to set the href URL links for regular downloads and onlick () to call the javascript function that does the AJAX download. However, they both shoot when I click the link, leaving the page completely refreshed.
Is there a way to prevent the use of "href" when using Javascript?